File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed
Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1135,7 +1135,17 @@ WritableImpl<Self>::WritableImpl(
11351135template <typename Self>
11361136jsg::Promise<void > WritableImpl<Self>::abort(
11371137 jsg::Lock& js, jsg::Ref<Self> self, v8::Local<v8::Value> reason) {
1138- signal->triggerAbort (js, jsg::JsValue (reason));
1138+ // Per the spec, the signal.reason should be a DOMException with name 'AbortError'
1139+ // when no reason is provided, but the stored error should remain as the original reason.
1140+ auto signalReason = [&]() -> jsg::JsValue {
1141+ if (reason->IsUndefined () && FeatureFlags::get (js).getPedanticWpt ()) {
1142+ auto ex = js.domException (
1143+ kj::str (" AbortError" ), kj::str (" This writable stream has been aborted." ), kj::none);
1144+ return jsg::JsValue (KJ_ASSERT_NONNULL (ex.tryGetHandle (js)));
1145+ }
1146+ return jsg::JsValue (reason);
1147+ }();
1148+ signal->triggerAbort (js, signalReason);
11391149
11401150 // We have to check this again after the AbortSignal is triggered.
11411151 if (state.template is <StreamStates::Closed>() || state.template is <StreamStates::Errored>()) {
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ wpt_test(
111111wpt_test (
112112 name = "streams" ,
113113 size = "large" ,
114+ compat_flags = ["pedantic_wpt" ],
114115 config = "streams-test.ts" ,
115116 wpt_directory = "@wpt//:streams@module" ,
116117)
Original file line number Diff line number Diff line change @@ -734,7 +734,6 @@ export default {
734734 "Aborting a WritableStream before it starts should cause the writer's unsettled ready promise to reject" ,
735735 "WritableStream if sink's abort throws, the promise returned by multiple writer.abort()s is the same and rejects" ,
736736 'when calling abort() twice on the same stream, both should give the same promise that fulfills with undefined' ,
737- 'the abort signal is signalled synchronously - write' ,
738737 'Aborting a WritableStream causes any outstanding write() promises to be rejected with the reason supplied' ,
739738 'Aborting a WritableStream puts it in an errored state with the error passed to abort()' ,
740739 'if a writer is created for a stream with a pending abort, its ready should be rejected with the abort error' ,
You can’t perform that action at this time.
0 commit comments