Skip to content

Fix trailing uncovered chunk generation in chunkify#86

Merged
bartveneman merged 1 commit intomainfrom
claude/review-lib-architecture-25k4K
Mar 17, 2026
Merged

Fix trailing uncovered chunk generation in chunkify#86
bartveneman merged 1 commit intomainfrom
claude/review-lib-architecture-25k4K

Conversation

@bartveneman
Copy link
Member

Summary

Fixed a bug in the chunkify function where the condition for appending a trailing uncovered chunk was incorrect, causing it to miss the last byte when it wasn't covered by any range.

Changes

  • Fixed boundary condition: Changed the condition from offset !== stylesheet.text.length - 1 to offset < stylesheet.text.length to correctly detect when a trailing uncovered chunk should be appended
  • Added test coverage:
    • Test for including a trailing uncovered chunk when the last byte is not covered
    • Test to ensure no spurious empty chunk is emitted when the last byte is fully covered

Implementation Details

The original condition used !== which only appended a chunk when the offset was not exactly one position before the end. This failed to handle the case where the last byte needed to be marked as uncovered. The corrected condition < properly checks if there are any remaining bytes after the current offset that need to be included in the coverage map.

https://claude.ai/code/session_01CyibEZDpRhyvg4fw3edy1Z

The condition `offset !== text.length - 1` incorrectly skipped the
trailing uncovered chunk when exactly one byte remained, silently
dropping the last byte. Changed to `offset < text.length`.

https://claude.ai/code/session_01CyibEZDpRhyvg4fw3edy1Z
@bartveneman bartveneman marked this pull request as ready for review March 17, 2026 20:38
@bartveneman bartveneman merged commit 1474fee into main Mar 17, 2026
6 of 7 checks passed
@bartveneman bartveneman deleted the claude/review-lib-architecture-25k4K branch March 17, 2026 20:38
@codecov-commenter
Copy link

Bundle Report

Changes will decrease total bundle size by 6 bytes (-0.02%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
index.js-esm 12.12kB -6 bytes (-0.05%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: index.js-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js -6 bytes 10.76kB -0.06%

Files in index.js:

  • ./src/lib/chunkify.ts → Total Size: 1.53kB

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.07%. Comparing base (2a325c2) to head (da982fe).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #86      +/-   ##
==========================================
- Coverage   96.56%   96.07%   -0.50%     
==========================================
  Files          14       14              
  Lines        1020     1020              
  Branches      136      136              
==========================================
- Hits          985      980       -5     
- Misses         34       39       +5     
  Partials        1        1              

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

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