diff --git a/lib/internal/streams/iter/from.js b/lib/internal/streams/iter/from.js index ab786dc3825..e434ff9c253 100644 --- a/lib/internal/streams/iter/from.js +++ b/lib/internal/streams/iter/from.js @@ -738,7 +738,7 @@ function fromSync(input) { if (!isIterable && isAsyncIterable(input)) { throw new ERR_INVALID_ARG_TYPE( 'input', - 'a synchronous input (not AsyncIterable)', + 'a synchronous input, not an async iterable', input, ); } @@ -748,7 +748,7 @@ function fromSync(input) { typeof input.then === 'function') { throw new ERR_INVALID_ARG_TYPE( 'input', - 'a synchronous input (not Promise)', + 'a synchronous input, not a promise', input, ); } diff --git a/test/parallel/test-stream-iter-from-sync.js b/test/parallel/test-stream-iter-from-sync.js index af7acfd4a54..133597914c4 100644 --- a/test/parallel/test-stream-iter-from-sync.js +++ b/test/parallel/test-stream-iter-from-sync.js @@ -183,7 +183,10 @@ function testFromSyncIgnoresAsyncStreamable() { // Explicit async iterable rejected function testFromSyncRejectsAsyncIterable() { async function* gen() { yield [new TextEncoder().encode('a')]; } - assert.throws(() => fromSync(gen()), { code: 'ERR_INVALID_ARG_TYPE' }); + assert.throws(() => fromSync(gen()), { + code: 'ERR_INVALID_ARG_TYPE', + message: /must be a synchronous input, not an async iterable\./, + }); } function testFromSyncPrefersIteratorForDualIterable() { @@ -212,8 +215,10 @@ function testFromSyncPrefersIteratorForThenableIterable() { // Promise rejected function testFromSyncRejectsPromise() { - assert.throws(() => fromSync(Promise.resolve('hello')), - { code: 'ERR_INVALID_ARG_TYPE' }); + assert.throws(() => fromSync(Promise.resolve('hello')), { + code: 'ERR_INVALID_ARG_TYPE', + message: /must be a synchronous input, not a promise\./, + }); } // DataView input should be converted to Uint8Array (zero-copy)