GeezerVison is showing github.com — stream: fix fromSync() async input error messages · nodejs/node@2184500
File treeExpand 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/from.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -700,7 +700,7 @@ function fromSync(input) { | 700 | 700 | if (!isIterable && isAsyncIterable(input)) { | 701 | 701 | throw new ERR_INVALID_ARG_TYPE( | 702 | 702 | 'input', | 703 | | - 'a synchronous input (not AsyncIterable)', | | 703 | + 'a synchronous input, not an async iterable', | 704 | 704 | input, | 705 | 705 | ); | 706 | 706 | } | @@ -710,7 +710,7 @@ function fromSync(input) { | 710 | 710 | typeof input.then === 'function') { | 711 | 711 | throw new ERR_INVALID_ARG_TYPE( | 712 | 712 | 'input', | 713 | | - 'a synchronous input (not Promise)', | | 713 | + 'a synchronous input, not a promise', | 714 | 714 | input, | 715 | 715 | ); | 716 | 716 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-stream-iter-from-sync.js +8-3Lines changed: 8 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -183,7 +183,10 @@ function testFromSyncIgnoresAsyncStreamable() { | 183 | 183 | // Explicit async iterable rejected | 184 | 184 | function testFromSyncRejectsAsyncIterable() { | 185 | 185 | async function* gen() { yield [new TextEncoder().encode('a')]; } | 186 | | - assert.throws(() => fromSync(gen()), { code: 'ERR_INVALID_ARG_TYPE' }); | | 186 | + assert.throws(() => fromSync(gen()), { | | 187 | + code: 'ERR_INVALID_ARG_TYPE', | | 188 | + message: /must be a synchronous input, not an async iterable\./, | | 189 | + }); | 187 | 190 | } | 188 | 191 |
| 189 | 192 | function testFromSyncPrefersIteratorForDualIterable() { | @@ -212,8 +215,10 @@ function testFromSyncPrefersIteratorForThenableIterable() { | 212 | 215 |
| 213 | 216 | // Promise rejected | 214 | 217 | function testFromSyncRejectsPromise() { | 215 | | - assert.throws(() => fromSync(Promise.resolve('hello')), | 216 | | - { code: 'ERR_INVALID_ARG_TYPE' }); | | 218 | + assert.throws(() => fromSync(Promise.resolve('hello')), { | | 219 | + code: 'ERR_INVALID_ARG_TYPE', | | 220 | + message: /must be a synchronous input, not a promise\./, | | 221 | + }); | 217 | 222 | } | 218 | 223 |
| 219 | 224 | // DataView input should be converted to Uint8Array (zero-copy) | |
|