Skip to content
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

build(webpack): fix --zip in Node.js 22 by cloning assets into Uint8Arrays before zipping #29177

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

davidmurdoch
Copy link
Contributor

@davidmurdoch davidmurdoch commented Dec 12, 2024

Use a copy of the Buffer via Buffer.from(asset), as Zip will consume it, which breaks things if we are compiling for multiple browsers at once. Buffer.from uses the internal pool, so it's superior to new Uint8Array if we don't need to pass it off to a worker thread.

Additionally, in Node.js 22+ a Buffer marked as "Untransferable" (like ours) can't be passed to a worker, which AsyncZipDeflate uses. See: 101arrowz/fflate#227 (comment)

This can probably be simplified to zipFile.push(Buffer.from(asset), true); if the above issue is resolved.

This fix should hopefully unblock #28368

@davidmurdoch davidmurdoch changed the title build(webpack): fix --zip in Node.js 22 by cloning assets into Uint8Arrays before zipping build(webpack): fix --zip in Node.js 22 by cloning assets into Uint8Arrays before zipping Dec 12, 2024
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot
Copy link
Collaborator

Builds ready [a77c7d3]
Page Load Metrics (1569 ± 39 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1438169215717536
domContentLoaded1398166515407737
load1409169215698039
domInteractive217741178
backgroundConnect968292010
firstReactRender156825188
getState45321199
initialActions01000
loadScripts1037128411666833
setupStore610711
uiStartup1606189617598943
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@davidmurdoch davidmurdoch marked this pull request as ready for review December 16, 2024 15:15
@HowardBraham HowardBraham added this pull request to the merge queue Dec 16, 2024
Merged via the queue into main with commit 58ca7af Dec 16, 2024
85 checks passed
@HowardBraham HowardBraham deleted the webpack-fix-zip-node-22 branch December 16, 2024 18:09
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2024
@metamaskbot metamaskbot added the release-12.11.0 Issue or pull request that will be included in release 12.11.0 label Dec 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.11.0 Issue or pull request that will be included in release 12.11.0 team-extension-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants