GeezerVison is showing github.com — stream: preserve push signal abort reason · nodejs/node@2632d60
File tree
Expand file treeCollapse file tree
Open diff view settings
lib/internal/streams/iter
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/streams/iter/push.js +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,7 +25,7 @@ const { |
25 | 25 | ERR_INVALID_STATE, |
26 | 26 | }, |
27 | 27 | } = require('internal/errors'); |
28 | | -const { isError, lazyDOMException } = require('internal/util'); |
| 28 | +const { lazyDOMException } = require('internal/util'); |
29 | 29 | const { |
30 | 30 | validateAbortSignal, |
31 | 31 | validateInteger, |
@@ -135,9 +135,7 @@ class PushQueue { |
135 | 135 |
|
136 | 136 | if (this.#signal) { |
137 | 137 | this.#abortHandler = () => { |
138 | | - this.fail(isError(this.#signal.reason) ? |
139 | | - this.#signal.reason : |
140 | | - lazyDOMException('Aborted', 'AbortError')); |
| 138 | + this.fail(this.#signal.reason); |
141 | 139 | }; |
142 | 140 | onSignalAbort(this.#signal, this.#abortHandler); |
143 | 141 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-stream-iter-push-basic.js +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -107,6 +107,16 @@ async function testAbortSignal() { |
107 | 107 | ); |
108 | 108 | } |
109 | 109 |
|
| 110 | +async function testAbortSignalReason() { |
| 111 | + const reason = 'test reason'; |
| 112 | + const ac = new AbortController(); |
| 113 | + const { writer } = push({ signal: ac.signal }); |
| 114 | + |
| 115 | + ac.abort(reason); |
| 116 | + |
| 117 | + await assert.rejects(writer.write('data'), (err) => err === reason); |
| 118 | +} |
| 119 | + |
110 | 120 | async function testPreAbortedSignal() { |
111 | 121 | const { readable } = push({ signal: AbortSignal.abort() }); |
112 | 122 | await assert.rejects(async () => { |
@@ -172,6 +182,7 @@ Promise.all([ |
172 | 182 | testWriterFail(), |
173 | 183 | testConsumerBreak(), |
174 | 184 | testAbortSignal(), |
| 185 | + testAbortSignalReason(), |
175 | 186 | testPreAbortedSignal(), |
176 | 187 | testConsumerBreakWriteSyncReturnsFalse(), |
177 | 188 | testPushWithTransforms(), |
|