GeezerVison is showing github.com — stream: use cause options in AbortError constructors · nodejs/node@046deba
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/streams/add-abort-signal.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,7 +34,7 @@ module.exports.addAbortSignalNoValidate = function(signal, stream) { |
34 | 34 | return stream; |
35 | 35 | } |
36 | 36 | const onAbort = () => { |
37 | | - stream.destroy(new AbortError()); |
| 37 | + stream.destroy(new AbortError(undefined, { cause: signal.reason })); |
38 | 38 | }; |
39 | 39 | if (signal.aborted) { |
40 | 40 | onAbort(); |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/streams/duplexify.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -214,7 +214,8 @@ function fromAsyncGen(fn) { |
214 | 214 | const { chunk, done, cb } = await _promise; |
215 | 215 | process.nextTick(cb); |
216 | 216 | if (done) return; |
217 | | - if (signal.aborted) throw new AbortError(); |
| 217 | + if (signal.aborted) |
| 218 | + throw new AbortError(undefined, { cause: signal.reason }); |
218 | 219 | ({ promise, resolve } = createDeferredPromise()); |
219 | 220 | yield chunk; |
220 | 221 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/streams/end-of-stream.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -220,7 +220,9 @@ function eos(stream, options, callback) { |
220 | 220 | // Keep it because cleanup removes it. |
221 | 221 | const endCallback = callback; |
222 | 222 | cleanup(); |
223 | | - endCallback.call(stream, new AbortError()); |
| 223 | + endCallback.call( |
| 224 | + stream, |
| 225 | + new AbortError(undefined, { cause: options.signal.reason })); |
224 | 226 | }; |
225 | 227 | if (options.signal.aborted) { |
226 | 228 | process.nextTick(abort); |
|