DenoDDeno
Powered by
Mark GM
Denoβ€’16mo agoβ€’
3 replies
Mark G

Dealing with errors in Response streams?

I've encountered problems whilst attempting to stream Responses, and discovered that if an error is thrown within the stream it just seems to be completely swallowed.

Here's a simple example:

#!/usr/bin/env -S deno run --allow-net --watch

await Deno.serve(() => {
  return new Response(ReadableStream.from(content()));
}).finished;

// deno-lint-ignore require-yield
function* content() {
  throw new Error("EPIC FAIL");
}
#!/usr/bin/env -S deno run --allow-net --watch

await Deno.serve(() => {
  return new Response(ReadableStream.from(content()));
}).finished;

// deno-lint-ignore require-yield
function* content() {
  throw new Error("EPIC FAIL");
}


Hit the server and the request fails, but no errors are logged.

Is there a preferred way to handle the errors in a stream?
Or this is a bug in Deno? IMHO it feels like one, I wouldn't expects errors to just silently vanish like this.
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Rewind streams
BubblesBBubbles / help
4y ago
Sharing streams
BubblesBBubbles / help
4y ago
errors with auto completion
GiveMeFoxGGiveMeFox / help
2y ago
Errors in boilerplate code?
HudsyWudsyHHudsyWudsy / help
2y ago