Skip to content

fix(binding): avoid shared property leak warnings on process exit - #16117

Merged
LingyuCoder merged 1 commit into
mainfrom
fix-shared-properties-exit
Oct 16, 2026
Merged

LingyuCoder merged 1 commit into
mainfrom
fix-shared-properties-exit

Conversation

@SoonIter

Copy link
Copy Markdown
Member

Motivation

Fixes #16115. Since #15883, a main-thread process.exit() can print three NAPI-RS ObjectRef warnings after a successful compiler.close(). The shared accessor references intentionally live for the N-API environment lifetime, but forced process exit skips environment cleanup hooks before thread-local destruction.

Changes

Use ObjectRef<false> only for the environment-owned shared-property cache, avoiding misleading drop-time leak diagnostics during forced shutdown. Keep the existing cleanup hooks and registration-failure unref() path intact; normal environment and worker teardown still release the references.

Add subprocess regression coverage for natural exit, main-thread process.exit(), and worker process.exit(), each with exit codes 0 and 1. Each case populates all three caches, closes the compiler, and checks stderr and the exit status.

Validation on macOS arm64 / Node.js 24.20.0: the two forced main-thread exit cases fail against the published 2.2.9 binding with three warnings each; all six shutdown cases pass with the rebuilt binding. The existing shared-accessor lifecycle and worker tests also pass. Ran pnpm run build:binding:dev, pnpm run build:js, pnpm --dir tests/rspack-test run test -t shared-accessors (11 passed), and cargo fmt --all --check.

The original Rspress dead-anchor reproduction, with a fresh persistent cache and the rebuilt binding, still exits with code 1 and reports the anchor error, with zero ObjectRef warnings. The binding build used a temporary path wrapper for the existing build script's handling of spaces in the checkout path; no build-script changes are included.

Copilot AI balanced review requested due to automatic review settings October 16, 2026 08:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T08:31:24.462756Z 4e85eb9 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@SoonIter

Copy link
Copy Markdown
Member Author

@codex review

@LingyuCoder
LingyuCoder enabled auto-merge (squash) October 16, 2026 08:28
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 4e85eb9677

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (116c049dd9fa97f6169d3cbd1e784d85f58ea5c4) does not have baseline artifacts. Using commit 7baf94b42eb6075299fdc31b6942a298184b019a for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 536.4 KB 0 0
react-10k 5.4 MB 1.3 MB 0 0
react-1k 827.7 KB 225.2 KB 0 0
ui-components 4.7 MB 1.4 MB 0 0
react-5k 2.6 MB 670.6 KB 0 0

Generated by Rsdoctor GitHub Action

@github-actions

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 4e85eb9 to fix: stabilize module rendering order across platforms (#16100) by hai-x

🙈 Size remains the same at 67.60MB

@codspeed

codspeed Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 57 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing fix-shared-properties-exit (4e85eb9) with main (7baf94b)2

Open in CodSpeed

Footnotes

  1. 47 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. ↩

  2. No successful run was found on main (2ec60e0) during the generation of this report, so 7baf94b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@LingyuCoder
LingyuCoder merged commit 30827d6 into main Oct 16, 2026
@LingyuCoder
LingyuCoder deleted the fix-shared-properties-exit branch October 16, 2026 09:08
sebdanielsson added a commit to sebdanielsson/backstage that referenced this pull request Oct 29, 2026
Rspack 2.2.9 prints "ObjectRef is not unref, it considered as a memory
leak" on stderr when the CLI exits after a frontend build or dev server
run. This is fixed in 2.3.0 (web-infra-dev/rspack#16117), so require it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ521AnrvsZ2yy1AHJJK25
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@trafikverket.se>
sebdanielsson added a commit to sebdanielsson/backstage that referenced this pull request Oct 30, 2026
Rspack 2.2.9 prints "ObjectRef is not unref, it considered as a memory
leak" on stderr when the CLI exits after a frontend build or dev server
run. This is fixed in 2.3.0 (web-infra-dev/rspack#16117), so require it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ521AnrvsZ2yy1AHJJK25
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@trafikverket.se>
sebdanielsson added a commit to sebdanielsson/backstage that referenced this pull request Nov 2, 2026
Rspack 2.2.9 prints "ObjectRef is not unref, it considered as a memory
leak" on stderr when the CLI exits after a frontend build or dev server
run. This is fixed in 2.3.0 (web-infra-dev/rspack#16117), so require it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ521AnrvsZ2yy1AHJJK25
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@trafikverket.se>
sebdanielsson added a commit to sebdanielsson/backstage that referenced this pull request Nov 2, 2026
Rspack 2.2.9 prints "ObjectRef is not unref, it considered as a memory
leak" on stderr when the CLI exits after a frontend build or dev server
run. This is fixed in 2.3.0 (web-infra-dev/rspack#16117), so require it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ521AnrvsZ2yy1AHJJK25
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@trafikverket.se>
sebdanielsson added a commit to sebdanielsson/backstage that referenced this pull request Nov 2, 2026
Rspack 2.2.9 prints "ObjectRef is not unref, it considered as a memory
leak" on stderr when the CLI exits after a frontend build or dev server
run. This is fixed in 2.3.0 (web-infra-dev/rspack#16117), so require it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ521AnrvsZ2yy1AHJJK25
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@trafikverket.se>
sebdanielsson added a commit to sebdanielsson/backstage that referenced this pull request Nov 13, 2026
Require Rspack 2.3.2. Production builds with 2.0 to 2.3.1 turn JSON that
is re-exported through CommonJS, as in `module.exports =
require('./list.json')`, into `[0]` when app code calls array methods on
it (web-infra-dev/rspack#16398, fixed by
web-infra-dev/rspack#16418). Rspack 2.3.0 also stopped printing
"ObjectRef is not unref, it considered as a memory leak" on stderr when
the CLI exits (web-infra-dev/rspack#16117).

- Insert the lazy compilation middleware before the dev middleware instead
  of last, so that a proxy entry like `context: "/"` can't forward its
  trigger requests to the backend.
- Throw a clear error when the `proxy` configuration isn't an array. The
  new dev server no longer validates its options, and failed with
  "this.options.proxy is not iterable" for an object, or proxied nothing
  for a string.
- Turn off colors in the build's error and warning messages and in the
  `--stats` report, which Rspack 2 colors when it detects CI or a
  terminal.
- Look for the dev server overlay by its new id,
  `rspack-dev-server-client-overlay`, in the e2e test. With the old id its
  check for the ResizeObserver error could never fail.
- Remove the bundler stubs from the two `start` command tests. The repo
  test already mocks the package start command, and the package test
  loads Rspack's ESM: natively with `--experimental-vm-modules`, which
  `yarn test` sets, and transformed to CommonJS without it.
- Changeset: drop the Node.js 22.12 note, as Node.js 24.15.0 is the new
  minimum. Mention that `EXPERIMENTAL_LAZY_COMPILATION` now takes effect,
  that the new dev server, not Rspack itself, dropped the proxy options,
  and the new overlay ID.

Corrections to the upgrade commit: `@swc/helpers` was only an optional
peer of Rspack 1 too, and was installed through other packages. It is
still needed as a direct dependency, for the SWC loader's
`externalHelpers`. The proxy translation's comment now ties the match
with the legacy WebPack dev server to `context` only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ521AnrvsZ2yy1AHJJK25
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@trafikverket.se>
sebdanielsson added a commit to sebdanielsson/backstage that referenced this pull request Nov 14, 2026
Require Rspack 2.3.2. Production builds with 2.0 to 2.3.1 turn JSON that
is re-exported through CommonJS, as in `module.exports =
require('./list.json')`, into `[0]` when app code calls array methods on
it (web-infra-dev/rspack#16398, fixed by
web-infra-dev/rspack#16418). Rspack 2.3.0 also stopped printing
"ObjectRef is not unref, it considered as a memory leak" on stderr when
the CLI exits (web-infra-dev/rspack#16117).

- Insert the lazy compilation middleware before the dev middleware instead
  of last, so that a proxy entry like `context: "/"` can't forward its
  trigger requests to the backend.
- Throw a clear error when the `proxy` configuration isn't an array. The
  new dev server no longer validates its options, and failed with
  "this.options.proxy is not iterable" for an object, or proxied nothing
  for a string.
- Turn off colors in the build's error and warning messages and in the
  `--stats` report, which Rspack 2 colors when it detects CI or a
  terminal.
- Restore `NODE_ENV` after package builds. postcss-load-config, which
  loads their PostCSS configs, sets it to `development` when it isn't
  set. Rspack 2's CSS minifier now targets the app's browserslist
  config, whose environment follows `NODE_ENV`, so `repo build --all`
  minified app CSS for the `development` browsers after it had built a
  package with CSS.
- Look for the dev server overlay by its new id,
  `rspack-dev-server-client-overlay`, in the e2e test. With the old id its
  check for the ResizeObserver error could never fail.
- Remove the bundler stubs from the two `start` command tests. The repo
  test already mocks the package start command, and the package test
  loads Rspack's ESM: natively with `--experimental-vm-modules`, which
  `yarn test` sets, and transformed to CommonJS without it.
- Changeset: drop the Node.js 22.12 note, as Node.js 24.15.0 is the new
  minimum. Mention that `EXPERIMENTAL_LAZY_COMPILATION` now takes effect,
  that the new dev server, not Rspack itself, dropped the proxy options,
  the new overlay ID, and that production CSS now targets the app's
  browserslist configuration.

Corrections to the upgrade commit: `@swc/helpers` was only an optional
peer of Rspack 1 too, and was installed through other packages. It is
still needed as a direct dependency, for the SWC loader's
`externalHelpers`. The proxy translation's comment now ties the match
with the legacy WebPack dev server to `context` only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ521AnrvsZ2yy1AHJJK25
Claude-Session: https://claude.ai/code/session_01NqdyP2EWYueT54rNhZ6PDK
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@trafikverket.se>
sebdanielsson added a commit to sebdanielsson/backstage that referenced this pull request Nov 14, 2026
Require Rspack 2.3.2. Production builds with 2.0 to 2.3.1 turn JSON that
is re-exported through CommonJS, as in `module.exports =
require('./list.json')`, into `[0]` when app code calls array methods on
it (web-infra-dev/rspack#16398, fixed by
web-infra-dev/rspack#16418). Rspack 2.3.0 also stopped printing
"ObjectRef is not unref, it considered as a memory leak" on stderr when
the CLI exits (web-infra-dev/rspack#16117).

- Insert the lazy compilation middleware before the dev middleware instead
  of last, so that a proxy entry like `context: "/"` can't forward its
  trigger requests to the backend.
- Throw a clear error when the `proxy` configuration isn't an array. The
  new dev server no longer validates its options, and failed with
  "this.options.proxy is not iterable" for an object, or proxied nothing
  for a string.
- Turn off colors in the build's error and warning messages and in the
  `--stats` report, which Rspack 2 colors when it detects CI or a
  terminal.
- Restore `NODE_ENV` after package builds. postcss-load-config, which
  loads their PostCSS configs, sets it to `development` when it isn't
  set. Rspack 2's CSS minifier now targets the app's browserslist
  config, whose environment follows `NODE_ENV`, so `repo build --all`
  minified app CSS for the `development` browsers after it had built a
  package with CSS.
- Look for the dev server overlay by its new id,
  `rspack-dev-server-client-overlay`, in the e2e test. With the old id its
  check for the ResizeObserver error could never fail.
- Remove the bundler stubs from the two `start` command tests. The repo
  test already mocks the package start command, and the package test
  loads Rspack's ESM: natively with `--experimental-vm-modules`, which
  `yarn test` sets, and transformed to CommonJS without it.
- Changeset: drop the Node.js 22.12 note, as Node.js 24.15.0 is the new
  minimum. Mention that `EXPERIMENTAL_LAZY_COMPILATION` now takes effect,
  that the new dev server, not Rspack itself, dropped the proxy options,
  the new overlay ID, and that production CSS now targets the app's
  browserslist configuration.

Corrections to the upgrade commit: `@swc/helpers` was only an optional
peer of Rspack 1 too, and was installed through other packages. It is
still needed as a direct dependency, for the SWC loader's
`externalHelpers`. The proxy translation's comment now ties the match
with the legacy WebPack dev server to `context` only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ521AnrvsZ2yy1AHJJK25
Claude-Session: https://claude.ai/code/session_01NqdyP2EWYueT54rNhZ6PDK
Signed-off-by: Sebastian Danielsson <sebastian.danielsson@trafikverket.se>
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.

[Bug] process.exit() emits NAPI-RS ObjectRef warnings since Rspack 2.2.9

3 participants

⌂ 换网址