Skip to content

fix(runtime): backport printer position ownership - #2

Merged
vincentkoc merged 1 commit into
mainfrom
claude/fix-runtime-printer-position
Sep 25, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
claude/fix-runtime-printer-position

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What does this PR do?

Backport oven-sh/bun#42767, commit ef6f44f37d40e1405d94362d794fe95ace86faad, by Dylan Conway, preserving the original author and regression test.

A reused runtime printer cleared its output buffer but retained a separate signed byte counter. After more than 2 GiB of cumulative output, that counter became negative and mandatory keyword spaces disappeared (function named() became functionnamed()). Derive Writer::written() from the current buffer instead. This preserves the fork’s existing position semantics and removes the duplicated counter.

The production and test patch matches upstream exactly; the fork changelog is the only additional change. Production: +2/-10 lines. Tests: +35/-1 lines.

How did you verify your code works?

  • The exact unfixed fork binary, 1.4.3-canary.1+d33ade8b6, fails the upstream fixture: 2,100 reloads of a 1 MiB CommonJS module, followed by a named function, produce SyntaxError: Unexpected token '{' (exit 1).
  • Release build: 59 passed, 0 failed, including the 2 GiB regression (executed, not skipped), across runtime-transpiler.test.ts and dir.test.ts.
  • Debug/ASAN build: 272 passed, 0 failed, with 2 expected skips, 21 existing todos, 12 snapshots and 2,120 assertions across runtime-transpiler.test.ts, transpiler.test.js and dir.test.ts. This includes the existing single-character keyword-spacing regressions.
  • bun run rust:check-all: 12 targets passed, 0 failed, 0 skipped. This is compilation coverage, not a claim of execution on every platform.
  • Independent manual and automated review: no findings on bec52588f6ab55cdc1bfc09e18897dd5272fcae9; git diff --check passes.

Native proof ran on combined integration commit 9d7a8224f1616ec9ef8902ec83d11656b544036b, tree 84541a6175c3bb796e79d5e91d72c69a96b7d0ac, which also includes the separate directory-entry backport. The printer source and regression-test blobs are identical to this PR. Linux x86_64; Clang/LLVM 21.1.8; Rust nightly-2026-07-20. Release artifact SHA-256: 45a1a0327135f65080d9dc0f22221286b4e52c9cad3c50bf69adcaf9f8474951.

Backport upstream commit ef6f44f (oven-sh#42767), retaining the original runtime regression test. Derive the position from the current output buffer so reused printers do not accumulate a signed counter across modules.
@vincentkoc
vincentkoc merged commit 9d7a822 into main Sep 25, 2026
9 of 11 checks passed
@vincentkoc
vincentkoc deleted the claude/fix-runtime-printer-position branch September 25, 2026 11:08
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.

2 participants