Skip to content

fix(electron): preserve runtime rejection and exception policies - #8160

Closed
ShuaixinHuang wants to merge 2 commits into
morluto:mainfrom
ShuaixinHuang:codex/fix-electron-rejection-policy
Closed

ShuaixinHuang wants to merge 2 commits into
morluto:mainfrom
ShuaixinHuang:codex/fix-electron-rejection-policy

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #8253 at the author's request: #8253 . The replacement uses the same verified head commit; this PR retains the original discussion and validation record.

Review follow-up: revoked rejection reasons

A P1 review identified that Array.isArray throws for a revoked Proxy before the application's rejection handler receives its original reason. This was reproduced on the initial PR head: 1 failed / 107 passed. Shape collection now checks arrays only for object values and treats an inaccessible revoked object's shape as object; callable reasons retain function. The added regression verifies original reason/promise identity for revoked object, array, and callable proxies, with an unrevoked array-proxy control. The final complete file is 108 passed. A real Electron 33.4.11/public CLI scenario with an application rejection handler also completed 6/6 actions; its later ping requires that the original handler received the revoked reason. No review thread was automatically replied to or resolved.

Summary

Fixes #8146. Recording an unhandled rejection must not turn Electron's warning-only behavior into an uncaught exception or change its existing exception-handler policy.

Problem and expected behavior

The active hook installed once listeners for unhandledRejection and uncaughtException and threw from both. In a real Windows Electron 33.4.11 process, the same rejection continued with warnings without the hook but terminated with exit code 7 with it. A public CLI scenario using the baseline hook did not complete within a 30-second watchdog; its owned process tree was then terminated.

Change and scope

Observe unhandledRejection and uncaughtExceptionMonitor at process event dispatch, forwarding the original receiver, arguments, return value, and thrown exception. Add no exception listeners. This leaves the runtime's default rejection mode and Electron/application listener counts intact, and records subsequent rejections too. Borrowed emit calls on other emitters are forwarded without process-event evidence.

The existing active-hook owner changes; no new provider, execution authority, public schema, limit, or cleanup mechanism is introduced. Maintainer scope decision: not applicable to this ordinary correction within the existing active-capture boundary.

Contract and boundary impact

  • Semantic owner: scripts/electron-active-hook.cjs; its existing process-lifecycle timeline consumer and event shapes are retained.
  • CLI/MCP/catalog and installation contracts: unchanged. Both surfaces use the same capture provider; real MCP execution was not run for this change.
  • Compatibility: preserve warning-only rejection behavior, application handlers, and Node throw/strict fatal behavior. Do not replace Electron's exception policy with a new fallback.
  • Target authority and cleanup: still an explicitly selected owned Electron application. Test apps used isolated temporary profiles; no existing user application/profile/process was used.
  • Generated metadata/package impact: none.

Expected effects of the existing operation:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.

Validation

  • npm run test:focused -- tests/boundary/browser/electronActiveHook.test.ts: 108 passed, 3 prerequisite build tasks passed. Six new cases cover revoked rejection reasons, warning-only ordinary and blocked-shell rejections, listener identity/throws and borrowed emit, Electron-style listener-count handling, and both fatal rejection modes. All 102 existing cases remain.
  • Controlled restoration of the hook to exact base e5c46dff034fef432e772f669bc309f512a6b186, with the initial five regressions: 5 failed / 102 passed. Executed bytes matched the Git baseline SHA-256; the patch was restored byte-for-byte in finally.
  • Real cached Electron 33.4.11, Windows x64: the unhooked control and fixed hook both continued, warned, and exited 0. The fixed hook also retained the rejection event; the original hook exited 7 before continuing.
  • Real compiled public capture-electron-scenario: fixed hook completed all 6/6 actions, retaining 2 unhandled-rejection events, the blocked shell attempt, and the later ping IPC invocation. The result retained its normal partial_attach coverage. The baseline run exceeded the external 30-second watchdog with no JSON result; only its owned process tree was terminated. A subsequent process inventory found no remaining probe processes.
  • npm run check:fast: 2/2 passed (31.59s); normal pre-commit passed; all three committed files match the verified hashes; normal pre-push 2/2 cached passed (288ms).

Compatibility, safety, and release

No breaking schema or migration. Payload values remain excluded from the timeline. Validation used the existing local Electron cache and Node 24.22.1; it does not establish Electron 44.7.0/Linux/Xvfb or macOS coverage from the report. No full repository suite or real MCP result is claimed. The CLI watchdog result is a bounded incomplete baseline run, not a successful cancellation/partial-Evidence test.

Author readiness

Human owner: @ShuaixinHuang

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-30T17:42:52.775915Z
We couldn’t complete this review. Comment @codex review to try again.
173c6ec PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; the previous handler-blocking failure is fixed and no new actionable issues were found.

Summary

The hook observes process errors without adding exception handlers or replacing the runtime's existing policy.

  • Electron capture records process events without changing the app's exception policy.

Reviews (2) · Last reviewed commit: "fix(electron): retain rejection handlers..." · Reviewed by Greptile

Comment thread scripts/electron-active-hook.cjs Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working provider: electron Analysis provider / engine: electron

Projects

None yet

2 participants