Skip to content

test: cover a throwing export getter in the plugin object loader - #39998

Merged
Jarred-Sumner merged 1 commit into
mainfrom
farm/f42a17c3/object-loader-export-getter-test
Aug 22, 2026
Merged

Jarred-Sumner merged 1 commit into
mainfrom
farm/f42a17c3/object-loader-export-getter-test

Conversation

@robobun

@robobun robobun commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Fix

  • Test only. Adds describe("object loader with a throwing getter on an export") to test/js/bun/plugin/plugins.test.ts, next to the Bun.plugin: fix segfault when an object loader result's exports getter throws #37026 block for a throwing getter on the result's exports property.
  • Three cases: import() and require() of a build.module() result, and import() of a build.onLoad() result. Each checks that the caught error is the object the getter threw. The getter sits between two plain exports.
  • Verified: all three fail with USE_SYSTEM_BUN=1 (1.4.0-canary.1+6e906e468) and pass with a debug build of main at 40ef811. The full file passes there (45 tests).

Background

Notes

#39804 made generateObjectModuleSourceCode propagate an exception thrown
by a getter on the exports object of a loader: "object" result. It added
tests for the mock.module() entry point only. This adds the Bun.plugin
entry points: import() and require() of a build.module() result, and
import() of a build.onLoad() result. Each case checks that the importer
receives the getter's own error object.

Before #39804 the three cases print boom=undefined. They pass on main.
@robobun

robobun commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 12:09 PM PT - Aug 21st, 2026

✅ @robobun, your commit 2e7029c86575c26f97c5de8e098f37f417098a80 passed in Build #102770! 🎉


🧪   To try this PR locally:

bunx bun-pr 39998

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

bun-39998 --bun

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 29f611e6-7246-49f6-ab5b-933973e6c3e4

📥 Commits

Reviewing files that changed from the base of the PR and between 40ef811 and 2e7029c.

📒 Files selected for processing (1)
  • test/js/bun/plugin/plugins.test.ts

Included review availability: Your plan provides up to 5 included reviews per hour; 0 remain after this review.


Walkthrough

Changes

Object-loader getter error propagation

Layer / File(s) Summary
Throwing export fixture and subprocess assertions
test/js/bun/plugin/plugins.test.ts
Adds a shared sentinel error, a throwing boom export getter, and subprocess assertions for exact error identity and clean termination.
Module and onLoad propagation coverage
test/js/bun/plugin/plugins.test.ts
Tests getter error propagation through dynamic import(), require(), build.module, and build.onLoad.

Suggested reviewers: jarred-sumner

Merge Risk: ⚪ Minimal · up to 2e702

This PR adds localized coverage for throwing export getters without changing product or runtime behavior; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the added plugin test for a throwing export getter.
Description check ✅ Passed The description explains the problem, test scope, covered cases, and verification results, despite not using the template headings verbatim.
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.

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

@robobun

robobun commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: this PR carries the plugin test case from #33793, which is now closed as superseded by #39804. Ready for review.

How I checked the behavior:

Both automated reviews and the self-review below reported no findings. No open review threads.

@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 — test-only addition that mirrors the existing throwing exports getter block right above it.

What was reviewed:

  • Subprocess pattern matches the neighboring #37026 block: await using proc, concurrent pipe drain via Promise.all, exact stdout/stderr/exitCode assertions in the right order.
  • Identity check (e === globalThis.sentinel) is stronger than a message match; the success-path ns.boom print ensures the pre-#39804 undefined-export behavior produces distinguishable output so the test fails for the right reason.
  • it.concurrent is appropriate — each case is an independent hermetic subprocess with no shared state.
Extended reasoning...

Overview

Test-only PR adding one describe block with three it.concurrent cases to test/js/bun/plugin/plugins.test.ts. Covers the Bun.plugin entry points (build.module via import/require, and build.onLoad via import) into generateObjectModuleSourceCode when an individual export property's getter throws. #39804 fixed the behavior and tested only the mock.module() entry point; this fills in the plugin-side coverage that #33793 originally proposed.

Security risks

None. No production code touched. Tests spawn hermetic subprocesses via bunExe()/bunEnv with inline -e code, no filesystem writes, no network.

Level of scrutiny

Low. This is a near-verbatim structural copy of the adjacent describe("object loader with a throwing exports getter") block (from #37026), with the getter moved one level deeper (onto a property of exports rather than exports itself). The shared expectSentinel helper and report catch-block template are local to the new describe and don't affect other tests.

Other factors

  • Assertions are exact and can fail: expect(stdout).toBe("failed with sentinel\n") distinguishes the fixed behavior from the old boom=undefined output the PR description documents under USE_SYSTEM_BUN=1.
  • The sentinel identity check (e === globalThis.sentinel) verifies the thrown object reaches the importer as-is, not wrapped or stringified — a tighter invariant than the neighboring block's message check.
  • Pipes drained concurrently, await using for the subprocess, exit code asserted last — all per harness conventions.
  • The before/after plain exports around the throwing boom getter ensure the loop in generateObjectModuleSourceCode is mid-iteration when the throw happens, which is the interesting case.
  • No prior reviews from me on this PR; only the robobun build comment in the timeline.

@robobun

robobun commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Self-review of this PR, done after the two automated reviews above.

Questions I checked:

No changes needed from this pass. The PR is ready for review.

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.

3 participants