Skip to content

Migrate zlib from jsg::BufferSource to jsg::JsArrayBufferView#6356

Merged
jasnell merged 2 commits intomainfrom
jasnell/zlib-no-buffersource
Mar 19, 2026
Merged

Migrate zlib from jsg::BufferSource to jsg::JsArrayBufferView#6356
jasnell merged 2 commits intomainfrom
jasnell/zlib-no-buffersource

Conversation

@jasnell
Copy link
Collaborator

@jasnell jasnell commented Mar 18, 2026

jsg::BufferSource is too heavyweight for the simple uses in zlib.

@jasnell jasnell requested review from a team as code owners March 18, 2026 22:38
ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk

This comment was marked as resolved.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 70 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing jasnell/zlib-no-buffersource (39b509a) with main (d3d5f2e)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.68%. Comparing base (d3d5f2e) to head (39b509a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6356   +/-   ##
=======================================
  Coverage   70.68%   70.68%           
=======================================
  Files         420      420           
  Lines      113025   113016    -9     
  Branches    18534    18533    -1     
=======================================
- Hits        79893    79887    -6     
  Misses      22086    22086           
+ Partials    11046    11043    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

jasnell added 2 commits March 19, 2026 10:22
The previous clearBuffers() fix (bea11e5) placed explicit calls after
updateWriteResult(). If updateWriteResult() throws (e.g. when the
writeState buffer passed to initialize() has fewer than 2 uint32
elements), the exception unwinds the stack before clearBuffers() is
reached, leaving z_stream.next_out pointing into the output buffer's
BackingStore. Once GC frees that memory, a subsequent params() call
triggers deflateParams() -> flush_pending() writing to freed memory.

Replace the three explicit clearBuffers() calls with a single KJ_DEFER
at the top of writeStream(). This guarantees the pointers are cleared
on every scope exit, including exception unwinding.
@jasnell jasnell force-pushed the jasnell/zlib-no-buffersource branch from d45ddc3 to 39b509a Compare March 19, 2026 17:22
@jasnell jasnell merged commit 10aa93b into main Mar 19, 2026
22 of 25 checks passed
@jasnell jasnell deleted the jasnell/zlib-no-buffersource branch March 19, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants