-
-
Couldn't load subscription status.
- Fork 33.6k
lib,streams: check SharedArrayBuffer existence in fast-utf8-stream
#60453
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
base: main
Are you sure you want to change the base?
Conversation
|
Review requested:
|
| const haveSAB = typeof SharedArrayBuffer !== 'undefined'; | ||
| const kNil = haveSAB ? new Int32Array(new SharedArrayBuffer(4)) : null; |
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.
Is the haveSAB variable useful?
| const haveSAB = typeof SharedArrayBuffer !== 'undefined'; | |
| const kNil = haveSAB ? new Int32Array(new SharedArrayBuffer(4)) : null; | |
| const kNil = SharedArrayBuffer && new Int32Array(new SharedArrayBuffer(4)); |
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.
@aduh95 we need it below to choose sleep implementation, no?
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.
We could use kNil for that
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.
The suggested code would throw an error if SharedArrayBuffer is not defined.
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.
It is declared above, it wouldn't throw even if undefined:
| SharedArrayBuffer, |
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.
lgtm
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #60453 +/- ##
==========================================
- Coverage 88.59% 88.58% -0.01%
==========================================
Files 704 704
Lines 207774 207831 +57
Branches 40035 40044 +9
==========================================
+ Hits 184068 184107 +39
- Misses 15748 15761 +13
- Partials 7958 7963 +5
🚀 New features to boost your workflow:
|
Refs #58897
Fixes the following error:
caused by changes in the above PR that declare
const kNil = new Int32Array(new SharedArrayBuffer(4));whenlib/internal/streams/fast-utf8-stream.jsis imported andUtf8Stream()is used. This causes an error in any environment missing aSharedArrayBuffer.I used an alternative
sleepimplementation in the missing case, but am happy to rework this however is preferred.