Skip to content

Conversation

@codebytere
Copy link
Member

Refs #58897

Fixes the following error:

"Uncaught ReferenceError: SharedArrayBuffer is not defined"

caused by changes in the above PR that declare const kNil = new Int32Array(new SharedArrayBuffer(4)); when lib/internal/streams/fast-utf8-stream.js is imported and Utf8Stream() is used. This causes an error in any environment missing a SharedArrayBuffer.

I used an alternative sleep implementation in the missing case, but am happy to rework this however is preferred.

@codebytere codebytere requested a review from jasnell October 28, 2025 08:04
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels Oct 28, 2025
Comment on lines +52 to +53
const haveSAB = typeof SharedArrayBuffer !== 'undefined';
const kNil = haveSAB ? new Int32Array(new SharedArrayBuffer(4)) : null;
Copy link
Contributor

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?

Suggested change
const haveSAB = typeof SharedArrayBuffer !== 'undefined';
const kNil = haveSAB ? new Int32Array(new SharedArrayBuffer(4)) : null;
const kNil = SharedArrayBuffer && new Int32Array(new SharedArrayBuffer(4));

Copy link
Member Author

@codebytere codebytere Oct 28, 2025

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?

Copy link
Contributor

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

Copy link
Member

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.

Copy link
Contributor

@aduh95 aduh95 Oct 28, 2025

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:

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.58%. Comparing base (ddbe136) to head (6547f21).
⚠️ Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/streams/fast-utf8-stream.js 50.00% 4 Missing ⚠️
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     
Files with missing lines Coverage Δ
lib/internal/streams/fast-utf8-stream.js 73.91% <50.00%> (-0.30%) ⬇️

... and 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants