Skip to content

Commit 1683353

Browse files
jasnellrichardlau
authored andcommitted
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 <[email protected]> PR-URL: #66483 Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 9648a6b commit 1683353

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎lib/internal/streams/iter/from.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ function fromSync(input) {
738738
if (!isIterable && isAsyncIterable(input)) {
739739
throw new ERR_INVALID_ARG_TYPE(
740740
'input',
741-
'a synchronous input (not AsyncIterable)',
741+
'a synchronous input, not an async iterable',
742742
input,
743743
);
744744
}
@@ -748,7 +748,7 @@ function fromSync(input) {
748748
typeof input.then === 'function') {
749749
throw new ERR_INVALID_ARG_TYPE(
750750
'input',
751-
'a synchronous input (not Promise)',
751+
'a synchronous input, not a promise',
752752
input,
753753
);
754754
}

‎test/parallel/test-stream-iter-from-sync.js‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ function testFromSyncIgnoresAsyncStreamable() {
183183
// Explicit async iterable rejected
184184
function testFromSyncRejectsAsyncIterable() {
185185
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+
});
187190
}
188191

189192
function testFromSyncPrefersIteratorForDualIterable() {
@@ -212,8 +215,10 @@ function testFromSyncPrefersIteratorForThenableIterable() {
212215

213216
// Promise rejected
214217
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+
});
217222
}
218223

219224
// DataView input should be converted to Uint8Array (zero-copy)

0 commit comments

Comments
 (0)