WICG / serial

Serial ports API for the platform.
https://wicg.github.io/serial/
Other
255 stars 46 forks source link

Listen for AbortSignal in writeAlgorithm #160

Closed reillyeon closed 2 years ago

reillyeon commented 2 years ago

When controller.signal is aborted, abort the current write operation so that the stream can close more quickly.

Partially resolves #152.

reillyeon commented 2 years ago

This specifies the behavior implemented in https://chromium-review.googlesource.com/c/chromium/src/+/3366788 and so resolves an issue which has been confusing me for awhile about one of the tests I wrote for aborting a stream while there was a write pending. This doesn't add any steps to closeAlgorithm but as implemented this would also unblock a close() as well.

reillyeon commented 2 years ago

While you're adding better hooks I noticed that "set up" doesn't take a startAlgorithm and that would be a better place to add abort steps than every time writeAlgorithm is invoked.

domenic commented 2 years ago

Oh, the intention was that startAlgorithm wasn't needed since you could just do that yourself as a sibling step of "set up". I think that works, if I expose "stream's signal"?

reillyeon commented 2 years ago

Oh, the intention was that startAlgorithm wasn't needed since you could just do that yourself as a sibling step of "set up". I think that works, if I expose "stream's signal"?

That's an excellent point.