Commit b5a14634e53 for nodejs
commit b5a14634e53b0ae291e96765cfd25c78bc4d7cfd
Author: James M Snell <jasnell@gmail.com>
Date: Sat Oct 3 15:11:20 2026 +0000
stream: fix fromSync() async input error messages
The ERR_INVALID_ARG_TYPE messages for async iterable and promise inputs
read "must be an a synchronous input (not AsyncIterable)", because the
error formatter adds "an" to expected-type strings that contain
uppercase letters. Rephrase them in lowercase.
Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66483
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
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)