whatwg / fetch

Fetch Standard
https://fetch.spec.whatwg.org/
Other
2.12k stars 333 forks source link

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

Open saschanaz opened 1 year ago

saschanaz commented 1 year ago
new Response(new ReadableStream({
  pull(c) {
    c.error("oh");
  }
})).text()

Different browsers do different things:

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

domenic commented 1 year ago

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 https://github.com/whatwg/html/pull/5749 but got stalled. (I guess Firefox implemented something without a spec.)

annevk commented 1 year ago

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

saschanaz commented 1 year ago

Alright, in that case this depends on https://github.com/whatwg/webidl/pull/1179.