Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.7k
stream: refine stream/iter backpressure and error handling#63697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -33,8 +33,6 @@ const { | ||
| const { | ||
| drainableProtocol, | ||
| kSyncWriteAccepted, | ||
| kSyncWriteAcceptedOnFalse, | ||
| } = require('internal/streams/iter/types'); | ||
| const { | ||
| @@ -369,19 +367,6 @@ class PushQueue { | ||
| this.#pendingEnd = pending; | ||
| } | ||
| /** | ||
| * Force-enqueue chunks into the slots buffer, bypassing capacity checks. | ||
| * Used by PushWriter.writeSync() for 'block' policy where the data is | ||
| * accepted but false is returned as a backpressure signal. | ||
| */ | ||
| forceEnqueue(chunks) { | ||
| this.#slots.push(chunks); | ||
| for (let i = 0; i < chunks.length; i++) { | ||
| this.#bytesWritten += TypedArrayPrototypeGetByteLength(chunks[i]); | ||
| } | ||
| this.#resolvePendingReads(); | ||
| } | ||
| /** | ||
| * Wait for backpressure to clear (desiredSize > 0). | ||
| * @returns {Promise<void>} | ||
| @@ -563,16 +548,11 @@ class PushQueue { | ||
| class PushWriter { | ||
| #queue; | ||
| #syncWriteAccepted = false; | ||
| constructor(queue) { | ||
| this.#queue = queue; | ||
| } | ||
| [kSyncWriteAccepted]() { | ||
| return this.#syncWriteAccepted; | ||
| } | ||
| [drainableProtocol]() { | ||
| const desired = this.desiredSize; | ||
| if (desired === null) return null; | ||
| @@ -584,10 +564,6 @@ class PushWriter { | ||
| return this.#queue.desiredSize; | ||
| } | ||
| get [kSyncWriteAcceptedOnFalse]() { | ||
| return this.#queue.backpressurePolicy === 'block'; | ||
| } | ||
| write(chunk, options) { | ||
| if (!options?.signal && this.#queue.canWriteSync()) { | ||
| const bytes = toUint8Array(chunk); | ||
| @@ -612,36 +588,16 @@ class PushWriter { | ||
| } | ||
| writeSync(chunk) { | ||
| this.#syncWriteAccepted = false; | ||
| const bytes = toUint8Array(chunk); | ||
| const result = this.#queue.writeSync([bytes]); | ||
| if (!result && this.#queue.backpressurePolicy === 'block' && | ||
| this.#queue.desiredSize === 0) { | ||
| // Block policy: force-enqueue and return false as backpressure signal. | ||
| // Data IS accepted; false tells caller to slow down. | ||
| this.#queue.forceEnqueue([bytes]); | ||
| this.#syncWriteAccepted = true; | ||
| return false; | ||
| } | ||
| this.#syncWriteAccepted = result; | ||
| return result; | ||
| return this.#queue.writeSync([bytes]); | ||
jasnell marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| writevSync(chunks) { | ||
| this.#syncWriteAccepted = false; | ||
| if (!ArrayIsArray(chunks)) { | ||
| throw new ERR_INVALID_ARG_TYPE('chunks', 'Array', chunks); | ||
| } | ||
| const bytes = convertChunks(chunks); | ||
| const result = this.#queue.writeSync(bytes); | ||
| if (!result && this.#queue.backpressurePolicy === 'block' && | ||
| this.#queue.desiredSize === 0) { | ||
| this.#queue.forceEnqueue(bytes); | ||
| this.#syncWriteAccepted = true; | ||
| return false; | ||
| } | ||
| this.#syncWriteAccepted = result; | ||
| return result; | ||
| return this.#queue.writeSync(bytes); | ||
| } | ||
| end(options) { | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.