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
Check if ReadableStream
is locked in all exit cases
#5103
Merged
isomarcte
merged 3 commits into
http4s:main
from
armanbilge:readable-stream-cancellation
Aug 23, 2021
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with what you have, but this separates the creation of the message from the cancellation of the
ReadableStream
and flips the boolean order. Some people feel thatif (!condition)
is non-ideal because it can people will often miss the negation when skimming the code. I've not strong feelings here though, just a thought.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid points. IMO my two-liner comment draws attention to the conditional which really shouldn't be necessary (
!rs.locked
is the happy path), Firefox is doing something weird here that isn't described in the spec AFAICT. And I thinkrs.cancel()
is simple enough that seperating out the cases in a single expression makes it easy to follow the control flow here. All very subjective of course :)But your
ex.getLocalizedMessage()
is a good touch. Except it reminds me, for many exceptions isn't the messagenull
? Maybe we should doex.toString()
here so at least the exception class gets into the reason, if there is no message?Let's not kid ourselves, this is an ugly bit of code that's not helped by the fact the spec doesn't describe what kind of argument the
cancel
method takes. Note to self: fix thenull
thing in scala-js-dom.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of
.toString
on the exception myself. Yes, the message can benull
, butgetMessage
andgetLocalizedMessage
are the canonical interfaces to describe aThrowable
error. I'd only want to bypass that if the message wasnull
. If we really wanted to go down the path of trying to get the class name out if the mesage isnull
, there are methods that one can take to do so.That said, I'm fine with any of the encodings you proposed. This is highly subjective territory so whatever you choose you've my 👍.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, so much bike shed! Localized message it is. Now I just hope someone actually sees it and finds it useful to make it all worth our trouble 😆 its unclear in the spec if we are not merely filling a blackhole.