You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, but in that case I think you should have either reverted it to the version here without the cast, or more readably, assert that the type is a Promise<>, as that makes it clearer that you're not waiting for it.
The reason will be displayed to describe this comment to others. Learn more.
@urkerab the assert is intentional; this.peekBuffer returns Buffer | null | Promise<Buffer | null>, and if you call loadIntoBuffer immediately before it, it is guaranteed not to return a Promise.
...except in the case of a race condition from the await for the loadIntoBuffer... if you call read before the previous read has finished. Which is unsupported but perhaps should not cause spectacular bugs. Hm.
e91c4c5
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.
efa0af0#diff-4addb8467b884244c38b8e9762b165ceR255
Wow, apparently this was my fault. I wonder how that happened.
e91c4c5
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.
What I don't understand is why there isn't an
await
here (or inread()
).e91c4c5
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.
That's a good point, there probably should be.
e91c4c5
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.
@urkerab it turns out no, there 100% should not have been an
await
here:8b68cdd
e91c4c5
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.
Fair enough, but in that case I think you should have either reverted it to the version here without the cast, or more readably, assert that the type is a
Promise<>
, as that makes it clearer that you're not waiting for it.e91c4c5
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.
@urkerab the assert is intentional;
this.peekBuffer
returnsBuffer | null | Promise<Buffer | null>
, and if you callloadIntoBuffer
immediately before it, it is guaranteed not to return aPromise
....except in the case of a race condition from the
await
for theloadIntoBuffer
... if you callread
before the previousread
has finished. Which is unsupported but perhaps should not cause spectacular bugs. Hm.e91c4c5
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 pushed c8dfed1 which no longer casts and protects against the race.
We can support multiple
read
s in a row, but we have too many other things to support, so I'm putting that off.