Re: [whatwg/streams] Roll WPT for abort reason (PR #1189)

Looks like we also have some failing tests. Fun! 😛 

```
  × (reason: 'null') all the error objects should be the same object
  
    promise_rejects_dom: pipeTo rejects with AbortError function "function() { throw e }" threw null, not an object
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async Test.<anonymous> (http://127.0.0.1:39171/streams/piping/abort.any.js:67:7)

  × (reason: 'null') abort should prevent further reads
  
    promise_rejects_dom: pipeTo rejects with AbortError function "function() { throw e }" threw null, not an object
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async Test.<anonymous> (http://127.0.0.1:39171/streams/piping/abort.any.js:137:7)

  × (reason: 'null') all pending writes should complete on abort
  
    promise_rejects_dom: pipeTo rejects with AbortError function "function() { throw e }" threw null, not an object
        at async Test.<anonymous> (http://127.0.0.1:39171/streams/piping/abort.any.js:176:7)
```
It seems like the tests expect `controller.abort(null)` to behave like `controller.abort(undefined)`, meaning that the `AbortSignal` becomes aborted with an `AbortError`. However, [the spec](https://dom.spec.whatwg.org/commit-snapshots/4ca187f9ccd4b1548d87293307ee58430ef4908b/#abortsignal-signal-abort) says:
> 2. Set _signal_’s abort reason to _reason_ if it is given; otherwise to a new `"AbortError"` `DOMException`.

AFAIK "if it is given" means "if it is not `undefined`", so `null` should be passed through unmodified and `signal.reason` becomes `null`. At least, that's how it's implemented [in jsdom](https://github.com/jsdom/jsdom/blob/a3037212707dfdcfe3d21ec89aea33d4cc674a5f/lib/jsdom/living/aborting/AbortSignal-impl.js#L26) and [in Deno](https://github.com/denoland/deno/blob/ccd730a8b77c188657ec15b5d096f62a24bd0be6/ext/web/03_abort_signal.js#L48). [Node.js](https://github.com/nodejs/node/blob/7633c86eebbf6e381e60e63dc6e3eb36a3cce276/lib/internal/abort_controller.js#L108) doesn't seem to create an `AbortError` yet, instead it always passes `reason` unmodified.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1189#issuecomment-978266746

Received on Wednesday, 24 November 2021 21:39:41 UTC