Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the error from ReadableStream for Response methods via err.cause #1665

Open
saschanaz opened this issue Jun 2, 2023 · 3 comments
Open

Comments

@saschanaz
Copy link
Member

saschanaz commented Jun 2, 2023

new Response(new ReadableStream({
  pull(c) {
    c.error("oh");
  }
})).text()

Different browsers do different things:

  • Firefox logs a console message (invisible to JS)
  • Safari passes it to the message of DOMException (and thus objects may become [object Object] by stringification)
  • Chrome does not expose it in any way.

Should the spec define a way to do this? Maybe use the new error.cause?

@domenic
Copy link
Member

domenic commented Jun 3, 2023

I like using error.cause. The main issue here though is cross-realm serialization. I guess that mostly works for errors these days, although I wish someone (not me) had the time to make it work with the new error types and capabilities. I tried in whatwg/html#5749 but got stalled. (I guess Firefox implemented something without a spec.)

@annevk
Copy link
Member

annevk commented Jun 6, 2023

Seems reasonable, might require some Web IDL changes to be able to set this property?

@saschanaz saschanaz changed the title How to expose the error from ReadableStream for Response methods? Expose the error from ReadableStream for Response methods via err.cause Jul 4, 2023
@saschanaz
Copy link
Member Author

Alright, in that case this depends on whatwg/webidl#1179.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants