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>
This commit is contained in:
James M Snell committed 2026-10-10 17:56:23 +00:00
1 parent 1caad8efb4
commit b5a14634e5
2 files changed
+10 -5

No files matched your search

+2 -2
View File
@@ -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,
);
}
+8 -3
View File
@@ -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)