mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Fix malformed error message in ReadableStream.getReader
The error message for an invalid 'mode' argument in ReadableStream.getReader was missing the "must be" part, resulting in a confusing error message like: "The argument 'mode' byob. Received 'invalid'" This fix updates the error message to properly say: "The argument 'mode' must be 'byob'. Received 'invalid'" A regression test has been added to ensure the error message is correct. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -395,7 +395,7 @@ export function getReader(this, options) {
|
||||
return new ReadableStreamBYOBReader(this);
|
||||
}
|
||||
|
||||
throw $ERR_INVALID_ARG_VALUE("mode", mode, "byob");
|
||||
throw $ERR_INVALID_ARG_VALUE("mode", mode, "must be 'byob'");
|
||||
}
|
||||
|
||||
export function pipeThrough(this, streams, options) {
|
||||
|
||||
@@ -1142,3 +1142,17 @@ it("pipeThrough doesn't cause unhandled rejections on readable errors", async ()
|
||||
|
||||
expect(unhandledRejectionCaught).toBe(false);
|
||||
});
|
||||
|
||||
it("ReadableStream.getReader with invalid mode should show correct error message", () => {
|
||||
const stream = new ReadableStream();
|
||||
|
||||
// Test with invalid mode value
|
||||
try {
|
||||
stream.getReader({ mode: "invalid" });
|
||||
expect.unreachable("Should have thrown an error");
|
||||
} catch (error) {
|
||||
expect(error.code).toBe("ERR_INVALID_ARG_VALUE");
|
||||
expect(error.message).toContain("must be 'byob'");
|
||||
expect(error.message).toContain("mode");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user