Skip to content

bundler: run Bun.build plugin hooks in the AsyncLocalStorage stores of the Bun.build() call - #41562

Closed
robobun wants to merge 2 commits into
mainfrom
robobun/98827ce5/als-bundler-plugin-hooks
Closed

robobun wants to merge 2 commits into
mainfrom
robobun/98827ce5/als-bundler-plugin-hooks

Conversation

@robobun

@robobun robobun commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • A Bun.build() plugin registered inside AsyncLocalStorage.run() loses the caller's store in its hooks: als.getStore() in onResolve, onLoad and onEnd is undefined. setup() and onStart read the store. It never worked.
  • The bundle thread hands each hook to the JS thread as an event-loop task. dispatchRequest (JSBundlerPlugin.cpp:598) and JSBundlerPlugin__runOnEndCallbacks (:773) call it in the event loop's async context.

Fix

  • The plugin object of a Bun.build() call keeps the stores current at its creation, before the first setup(). Both dispatches enter them with an AsyncContextScope.
  • Correct because every hook passes these two calls, and the plugin object lives for one build. Its tombstone releases the stores, and the kept context has no Bun.ModuleGraph frames.
  • Verified: 6 new tests in test/bundler/bundler_plugin.test.ts, all fail on main. Also the other plugin, Bun.build, Bun.serve HTML and Bake suites.
  • Self-reviewed: 10 concerns raised, 10 addressed.

Background

  • AsyncLocalStorage is one slot per global. Native code that calls script later must restore it.
  • The plugin object (JSBundlerPlugin) is the native cell behind setup(build). After its tombstone it answers no request.
  • Considered a capture per hook registration in the builtin, as this PR did first: hooks get the registration store, every hook call allocates, getters stay bare.

Downsides

  • Cost with no store: +51 instructions per hook dispatch, +8 bytes in the plugin object, .text +1024 bytes.
  • Plugins of Bun.serve HTML routes and of Bake still see no store.
  • A build started with no store still reads another Bun.build() caller's store while that caller waits for an async setup().
Notes

An audit of AsyncLocalStorage propagation found this. No issue reports it. On released versions AsyncLocalStorage.bind() around each hook is the way to keep a store.

Repro

import { AsyncLocalStorage } from "node:async_hooks";
const als = new AsyncLocalStorage();
await als.run("build", () =>
  Bun.build({
    entrypoints: ["./entry.js"], // imports "virtual:a"
    plugins: [
      {
        name: "probe",
        setup(build) {
          build.onResolve({ filter: /^virtual:/ }, args => {
            console.log(als.getStore()); // main, 1.4.4, 1.4.0, 1.3.14: undefined. This PR: "build"
            return { path: args.path, namespace: "virtual" };
          });
          build.onLoad({ filter: /.*/, namespace: "virtual" }, () => ({ contents: "export default 1", loader: "js" }));
        },
      },
    ],
  }),
);

Two things for a maintainer to confirm

  1. The contract. A hook reads the stores of the Bun.build() call, read before the first setup() runs. It does not read the stores of its onLoad() / onResolve() / onEnd() registration call. This is the reverse of what this PR carried in September.
  2. The kept context has no Bun.ModuleGraph frames. The dispatch enters the graph that the event loop called the hook for again on top of the kept stores, as WebSocket does since WebSocket: real closing handshake, one failure path, ws rewritten on native transports (consolidates the open WebSocket PRs) #45223 (Bun::asyncContextWithoutModuleGraphs, Bun::ModuleGraphContextScope).

The contract

  • A hook that setup() registers inside als.run("registration"), or after an await, reads the store of the Bun.build() call. als.enterWith() inside setup() does not change what hooks read.
  • AsyncLocalStorage.bind(callback) is the opt-in for one hook: a bound hook keeps the store it was bound in, as on main.
  • One scope around the builtin call covers what the builtin does for the hook: later matching callbacks after an awaited one, getters on the object a hook returns, toJSON of exports, toString of a thrown value, code after an await or await args.defer(), an onEnd that a hook registers late, and onEnd of a failed build.
  • Other bundlers, on Node 26.3.0: rollup 4.4.1 runs hooks in the store of the rollup() call, not the store the plugin object was made in. esbuild 0.21.5 runs them in the store of the call that started its service. Neither runs a hook in the store of its registration.

Reading another caller's store

Why the plugin object and the two native calls

  • Every onResolve and onLoad request passes dispatchRequest, and every onEnd passes JSBundlerPlugin__runOnEndCallbacks. No other place sees all hooks. JSBundlerPlugin__runOnEndCallbacks had // TODO: use AsyncContextFrame? since Bundler changes to bring us closer to esbuild's api #22076.
  • The plugin object of Bun.build() lives for one build, so what it keeps is released with the build.
  • JSBundlerPlugin__create takes a required argument that says which stores the hooks run in. Each of its three callers states its choice:
    • Bun.build(): the caller's.
    • Bun.serve HTML routes (server_body.rs): none. The plugin object is made from the event loop at the first request. The store of the Bun.serve() call is not current there, and a capture would take whatever the event loop has at that moment.
    • Bake (bake/config/bundler.rs): none. Nothing tombstones a dev server's plugin object when the server stops (bake: consolidate the open robobun dev-server, HMR runtime, production build and router fixes #39488), so a kept context would never be released.
  • The first version of this PR captured the context per registration in BundlerPlugin.ts and ran each callback through internal/async_context_frame. None of it is kept. It gave hooks the registration store, added one rest array and one JS call per hook call for every plugin build, put the contexts into tuples that script can reach, and left getters, toJSON and the thrown-value path in the event loop's context.

Bun.ModuleGraph

  • The async context slot also carries Bun.ModuleGraph identity. On main the event loop already enters the caller's graph for both tasks, so a graph's build runs its hooks as the graph. That does not change: the test reads the graph and the host on both builds.
  • The plugin object is protected while its build runs. A kept context with graph frames would root the caller's graph. A first draft did that: a build that waits in a hook, started by a graph that the host drops, was never given up, the process did not exit, and the next host build stayed pending. With the frames removed, all four probes behave as on main, and a test pins it.
  • What the removal gives up: a build that a graph starts with no store keeps an empty context, so inside another caller's wait it reads that caller's store, as on main.

Lifetime

  • Script can keep the plugin object alive after the build: through the builder, its functions, an onLoad args object or args.defer. The tombstone clears the kept context, so a kept plugin object does not keep the store. Test: 5 finished builds with the builder kept, and no root reaches any of the 5 stores. Without the clear, the kept builder reaches all 5.
  • No hook is dispatched after the tombstone. When the calling Bun.ModuleGraph is disposed during the build, the requests that the plugins hold are cancelled and no onEnd runs, as on main.

Measurements

Release builds of main 92e819d and of this PR on it.

  • per plugin hook dispatch without AsyncLocalStorage: +51 instructions by disassembly (28 inline, 8 in the AsyncContextScope constructor, 15 in its destructor), 2 direct calls, 0 allocations, 0 slot writes. One scope per dispatch: 203 of 203 and 403 of 403 dispatches (gdb). The whole-process count per virtual import (one onResolve and one onLoad) is 832,326 on main and 832,293 here, spread 577 and 848: the change is inside the noise.
  • per hook call and per registration without AsyncLocalStorage: +0 rest arrays, +0 internal modules, +0 heap objects (gdb hit counts at N=100 and N=200, heapStats over 20,000 registrations).
  • per hook dispatch with a store current, no Bun.ModuleGraph in the process: +0 AsyncContextFrame wrappers, +0 rest arrays, +0 heap cells, at most 2 slot writes. One more Strong handle is freed per build.
  • per hook dispatch with a store current, in a process that made a Bun.ModuleGraph: a host build allocates and frees 1 Strong handle per dispatch (main 0). A graph's own build does that on main already (263 and 263 at N=100), and allocates 1 more heap cell per dispatch here: the graph frame that is entered on top.
  • per Bun.build() with plugins: one capture in JSBundlerPlugin__create, 0 new FFI calls, 0 new exported functions (15 JSBundlerPlugin__ symbols on both). Bun.build() without plugins: +0 (JSBundlerPlugin__create is not called).
  • JSBundlerPlugin: sizeof 360 to 368 bytes (lldb, debug builds). Allocated per cell: 362 and 362 bytes (estimateShallowMemoryUsageOf).
  • release binary: .text +1024 bytes. matchOnLoad +239, matchOnResolve +283, runOnEndCallbacks +247, create +76, tombstone +30, GC visitor +192 and +32 bytes (llvm-size -A and nm -S).
  • wall time per hook without AsyncLocalStorage: main 53.8 us, this PR 51.7 us, noise floor 32 us (20 interleaved runs each, 40,002 hook calls). The delta is below the noise floor.

Tests

Six subprocess fixtures in test/bundler/bundler_plugin.test.ts. All six fail on main.

  1. Hooks, what they await, and what the bundler reads from what they return or throw, with onEnd of a failed build under both throw states.
  2. A hook that setup() registers inside another store, or after an await.
  3. Two overlapping builds. The fixture asserts that the first build ended inside the second Bun.build() call, and that the second call reads its own store after the wait.
  4. A plugin object that script keeps does not keep the store: no root reaches it. A collection runs in the same turn as each Bun.build() call.
  5. A build that runs as a Bun.ModuleGraph. A host timer that ticks between the hooks reads no store and no graph.
  6. A build that waits in a hook does not keep the Bun.ModuleGraph that started it: no root reaches the graph.

Each part of the change removed alone fails a test: no restore at the end of the scope fails 3 and 5, no GC visit of the kept context fails 4, no tombstone clear fails 4, graph frames left in the kept context fail 6.

Tests 4 and 6 ask the heap what keeps the object alive. The section below says why.

Equal results on release builds of main and of this PR: bundler_plugin_chain, plugin-error-nested-throw, plugin-sync-exception-fallback, native-plugin, bun-build-api, test/js/bun/plugin/plugins.test.ts, bun-serve-html, test/bake/dev/plugins.test.ts, test/bake/serve-plugins-dev-server.test.ts, module-graph, module-graph-isolation, module-graph-callbacks, AsyncLocalStorage.test.ts. The new tests and the onEnd, resolve and load groups pass with BUN_JSC_validateExceptionChecks=1.

Why tests 4 and 6 read the heap

  • The first version of test 6 ran Bun.gc(true) in a loop until the graph was collected. In CI that loop did not collect the graph in any attempt on Windows 2019 x64 and Windows 11 aarch64. On alpine 3.23 x64, alpine 3.23 aarch64 and ubuntu 25.04 aarch64 it failed on the first attempt and passed on the second.
  • On linux x64 the same loop with setImmediate turns shows it. The graph is not collected after 200 collections in 31 of 40 runs on main 92e819d, and in 33 of 40 runs with this PR.
  • Nothing holds the graph through the heap in that state. generateHeapSnapshotForDebugging() gives the cells that reach it (five on main, six with this PR), and none of them is a root. The top one is a Promise with no incoming edge and no root entry. It is the result of the async arrow in runOnLoadPlugins for the hook that waits. Its .then() reaction keeps the async context of the dispatch, and that context names the graph.
graph not collected after 200 collections. 5 cells reach it. Roots among them: []
  d=1 Object#822 --Property:storage--> ModuleGraph#824
  d=1 JSLexicalEnvironment#830 --Variable:moduleGraph--> ModuleGraph#824
  d=2 FullPromiseReaction#820 --Internal--> Object#822
  d=2 ModuleLoader#828 --Internal--> Object#822
  d=3 Promise#818 --Internal--> FullPromiseReaction#820
  • A word on the native stack holds that Promise. gdb on main, stopped in JSC__VM__runGC in that state, with the frames from the frame pointer chain (abridged):
stopped in JSC__VM__runGC: rsp=0x7fffffffc120 rbp=0x7fffffffc170 stack base=0x7ffffffff000
   #3  fp=0x7fffffffc270  JS frame, the module code of the fixture
   #4  fp=0x7fffffffc320  llint_call_javascript + 6
   #5  fp=0x7fffffffc400  JSC::Interpreter::executeModuleProgram(...) + 659
   #6  fp=0x7fffffffc4a0  JSC::JSModuleRecord::evaluate(...) + 558
   #7  fp=0x7fffffffc4e0  JSC::asyncModuleExecutionResume(...) + 68
   #8  fp=0x7fffffffc5f0  JSC::runInternalMicrotask(...) + 8700
stack word at 0x7fffffffc358 holds 0x41459440de0 (Promise): frame #5 JSC::Interpreter::executeModuleProgram, at fp-168
stack word at 0x7fffffffc468 holds 0x41459440de0 (Promise): frame #6 JSC::JSModuleRecord::evaluate, at fp-56
2 stack words point into the cells that reach the graph. Scanned 12000 bytes, from rsp to the stack base.
  • With this PR it is one word, at fp-72 of JSC::JSModuleRecord::evaluate. The loop is the top-level await of the fixture, so each turn enters these two frames again at the same stack address. A hardware watchpoint on those words saw 0 writes over the next 3 turns, on main and with this PR.
  • Tests 4 and 6 now use Lifetimes from test/js/bun/module-graph/module-graph-lifetimes.ts, as the Bun.ModuleGraph collection tests do. It collects from a timer callback. For an object that is still not finalized it reads the heap snapshot, and reports the path from a root or nothing.
  • In the state above the graph was still held after the loop in 52 of 60 runs, and Lifetimes reported no root in 60 of 60. With graph frames left in the kept context it reported root(ProtectedValues) BundlerPlugin -Internal:0-> Frame -Property:prev-> Object -Property:storage-> ModuleGraph in 60 of 60.
  • Test 6 no longer waits for the next host build. That build starts only after a real collection of the graph.

Not changed here

Related


no test proof · iteration 2 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/bundler/bundler_plugin.test.ts

@robobun

robobun commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: reproduced on release builds of main (92e819d), 1.4.4, 1.4.0 and 1.3.14. A Bun.build() plugin registered inside AsyncLocalStorage.run() reads undefined in onResolve, onLoad and onEnd. The 6 new tests in test/bundler/bundler_plugin.test.ts fail on main and pass with this branch.

The PR has a new mechanism (c6219a9). The plugin object of a Bun.build() call keeps the stores of the call, and the two native dispatches in JSBundlerPlugin.cpp enter them. The September version captured the context per hook registration in BundlerPlugin.ts. None of it is kept.

The two lifetime tests ask the heap snapshot what keeps the object alive (019da83). The Notes of the PR body say why a collection alone cannot tell.

CI on 019da83 (build 133891): 180 of 181 jobs passed, and the 6 new tests pass on every lane, Windows included. One job failed: windows x64 - verify-baseline. A JPEG test in test/js/bun/jsc-stress/fixtures/simd-baseline.test.ts timed out at 5000 ms under CPU emulation. This PR does not touch that code. The same job failed with a 5000 ms timeout in that file on main builds 133501 and 133333. A retry of the failed job is enough.

It needs a maintainer to confirm two choices, listed first in the Notes of the PR body: hooks read the stores of the Bun.build() call and not of their registration, and the kept context has no Bun.ModuleGraph frames. The sibling PR for direct stream sources is #41561.

@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8a679da and c6219a9.

Files selected for processing: 6
  • src/jsc/bindings/JSBundlerPlugin.cpp
  • src/jsc/bindings/JSBundlerPlugin.h
  • src/runtime/api/JSBundler.rs
  • src/runtime/bake/config/bundler.rs
  • src/runtime/server/server_body.rs
  • test/bundler/bundler_plugin.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Walkthrough

Bun.build plugin creation now captures the caller’s async context. Resolve and load hooks, along with on-end callbacks, restore that context while using the active ModuleGraph. Other plugin creation paths select the event loop’s current context. Tests cover propagation, overlapping builds, graph isolation, and context collection.

Changes

Bundler plugin async context

Layer / File(s) Summary
Define and route plugin async-context modes
src/jsc/bindings/JSBundlerPlugin.h, src/runtime/api/JSBundler.rs, src/runtime/bake/config/bundler.rs, src/runtime/server/server_body.rs
The Rust and C++ interfaces define None and Caller modes. Bun.build() passes Caller; bake and server plugin creation pass None.
Capture and restore context for hooks
src/jsc/bindings/JSBundlerPlugin.cpp
The plugin stores caller context without module-graph frames. Hook dispatch and on-end callbacks enter that context with the active module graph. Tombstoning clears the stored context.
Validate build async-context propagation
test/bundler/bundler_plugin.test.ts
Tests check the async store observed by hooks, deferred work, result accessors, setup callbacks, and overlapping builds.
Validate context and module-graph lifetime
test/bundler/bundler_plugin.test.ts
Tests check collection of completed-build stores, hook execution in the build’s module graph, host state isolation, and behavior while a hook remains pending.

Possibly related PRs

  • oven-sh/bun#34112: Stores and restores the ModuleGraph for deferred virtual-module plugin results.
  • oven-sh/bun#46967: Captures and restores async context for HTMLRewriter transform handlers.
  • oven-sh/bun#41561: Covers async context in direct stream pull, cancel, and close callbacks.

Suggested reviewers: dylan-conway, alii

Priority: Normal

Merge Risk: Minimal · up to c6219

The change is mergeable after normal checks; no actionable issue remains identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly describes the main change: running Bun.build plugin hooks in the Bun.build() call's AsyncLocalStorage context.
Description check Passed The description follows the required template with both sections present. "### What does this PR do?" is covered by the Problem, Fix, Background, Downsides, and Notes content, which explain the bug, t…
Full details: Description check

Explanation

The description follows the required template with both sections present. "### What does this PR do?" is covered by the Problem, Fix, Background, Downsides, and Notes content, which explain the bug, the chosen fix, the contract, lifetime handling, and measured costs. "### How did you verify your code works?" is covered by the test count, the tests that fail on main, the test suites run on release builds, and the heap-based lifetime checks. The description is very long, and parts of it are detailed. Some items need attention. The evidence banner states "no test proof" for test/bundler/bundler_plugin.test.ts and defers to CI for platform-specific tests. The Notes block also contains two open questions for a maintainer to confirm, which are unresolved in the description itself.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 2:17 PM PT - Oct 27th, 2026

❌ @robobun, your commit 019da83 has 1 failures in Build #133891 (All Failures):

  • ❌ Baseline verification failed on Windows x64 — 1 check(s)
  • The baseline build crashed or failed tests under Nehalem (SSE4.2, no AVX/AVX2/AVX512) emulation (not an unsupported-instruction fault). See the step log for the crash output.

    • SIMD baseline tests

🧪   To try this PR locally:

bunx bun-pr 41562

That installs a local version of the PR into your bun-41562 executable, so you can run:

bun-41562 --bun

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — straightforward application of the existing internal/async_context_frame.run pattern to bundler plugin hooks.

What was reviewed:

  • run(frame, fn, thisArg?, ...args) signature matches all three call sites; thisArg: undefined preserves the original bare-call receiver, and .run uses .$apply internally so tamper-proofing holds.
  • Tuple shape change: other readers (for (var [filter] of callbacks) at addFilter, the merge loops) destructure by leading position only, and onBeforeParse keeps its 4-tuple — no consumer breaks.
  • onStart intentionally not touched: it invokes the callback synchronously inside runSetupFunction, so it already inherits the caller's frame (test asserts this).
  • Test follows conventions: tempDir, test.concurrent, single combined .toEqual; the Bun.sleep(0) exercises context propagation across an await, not a timing wait.
Extended reasoning...

Overview

The PR captures the active async-context frame ($getInternalField($asyncContext, 0)) alongside each onLoad/onResolve/onEnd callback at registration time in src/js/builtins/BundlerPlugin.ts, and dispatches through require("internal/async_context_frame").run so AsyncLocalStorage.getStore() works inside those hooks. The stored tuples grow from [filter, callback] to [filter, callback, asyncContext] (and onEndCallbacks becomes an array of [callback, asyncContext]). JSBundlerPlugin.cpp only drops a now-resolved TODO comment. A new concurrent test in test/bundler/bundler_plugin.test.ts verifies each hook — including after an await inside onLoad — sees the store from its registration frame.

Security risks

None. The change routes user callbacks through an internal helper that already uses tamper-proof .$apply, and the captured frame is an opaque internal-field value the user cannot forge. No new user-controlled input parsing, no auth/crypto/path handling.

Level of scrutiny

Low-to-moderate. This is a small, mechanical fix that mirrors the exact pattern already shipping in src/js/node/_http_client.ts and src/js/node/http2.ts (module-level const runInFrame = require("internal/async_context_frame").run; here it's per-builtin-function since builtins/ files are compiled as standalone functions with no shared module scope). I checked every other reader of the tuples in BundlerPlugin.ts — they either destructure only the leading [filter] or iterate the Map's [namespace, callbacks] entries — so the added third element is invisible to them. onBeforeParse keeps its [filter, napiModule, symbol, external] shape, which is correct since it's a native callback with no JS async context. onStart is correctly excluded because it calls the callback synchronously during setup (line 262).

Other factors

No CODEOWNERS cover these paths. The bug hunt exited on dry_streak with no findings and no ruled-out candidates. The PR timeline has no prior reviews or objections. The test uses harness tempDir, test.concurrent, a single combined-object .toEqual, and asserts a nested als.run("registration", ...) around onEnd to prove the capture point is registration rather than the outer Bun.build call — a meaningful distinction the fix's design implies. The one added source comment explains why the capture happens at registration (bundle thread dispatches later outside any JS frame), which is load-bearing rather than narration.

@robobun
robobun force-pushed the robobun/98827ce5/als-bundler-plugin-hooks branch from 6b20d21 to c348ee7 Compare September 6, 2026 10:30
Comment thread src/js/builtins/BundlerPlugin.ts Resolved

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

…f the Bun.build() call

The bundle thread hands each onResolve / onLoad request and the onEnd
callbacks to the JS thread as event-loop tasks. The two native calls that
dispatch them (dispatchRequest and JSBundlerPlugin__runOnEndCallbacks)
called the builtin in whatever async context the event loop had. A plugin
registered inside AsyncLocalStorage.run() never saw its store in a hook.

The plugin object of a Bun.build() call now keeps the stores that are
current when it is made, before the first setup() runs, and both
dispatches enter them for the call. The kept context has no
Bun.ModuleGraph frames, so a build does not keep the graph that started
it alive: the dispatch enters the graph the event loop called it for
again on top. The context is released at the tombstone, because script
can keep the plugin object after the build.

JSBundlerPlugin__create takes which stores the hooks run in, so each of
its three callers states it. The plugin object of Bun.serve is made from
the event loop at the first request, and nothing tombstones a dev
server's plugin object, so their hooks stay as they are.
@robobun
robobun force-pushed the robobun/98827ce5/als-bundler-plugin-hooks branch from 567f4ab to c6219a9 Compare October 27, 2026 18:06
@robobun robobun changed the title bundler: run plugin onResolve, onLoad and onEnd hooks in the AsyncLocalStorage context of their registration bundler: run Bun.build plugin hooks in the AsyncLocalStorage stores of the Bun.build() call Oct 27, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread src/jsc/bindings/JSBundlerPlugin.cpp Resolved
…tores alive

The two lifetime tests waited for a collection. JavaScriptCore also marks
what a word on the native stack points at, and a frame that the loop
enters again on each turn can keep such a word. The graph was then never
collected on Windows.

Both tests now use Lifetimes from the module graph tests. It asks the
heap snapshot if a root reaches the object. The graph test holds the
graph until the first hook has run, because a collection before that
gives the build up.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

@robobun

robobun commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as stale: this PR conflicts with main, and its last commit is from 2026-10-27.

The branch stays, so the work is not lost. To pick it up again, rebase the branch on main and reopen this PR.

@robobun robobun closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants