Repository navigation
fix(electron): reject non-executable paths and contain launch rejections - #2705
Conversation
An executable_path that runs but never prints the inspector line made Playwright's electron.launch() leave three waits unawaited. They rejected unhandled and Node ended the CLI or the MCP server (morluto#2269). Check the resolved executable_path is a regular file, and on non-Windows hosts that it passes X_OK, before any launch. Wrap only the launch call in a scoped unhandledRejection listener that absorbs rejections whose stack is in playwright-core/lib and re-throws anything else. Tested on Linux with Node 22.23.1, 24.18.0 and 26.11.1. Refs morluto#2269 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
The listener around the launch dropped every rejection with a playwright-core stack, so an unrelated Playwright failure during the launch window would vanish. Hold those rejections instead. When the launch settles, drop only the ones whose message is part of the launch's own error (the orphans of a failed launch). Raise every other one again through the unhandledRejection path, so the process still fails. A launch that succeeds raises all of them. Rejections without a Playwright stack still fail at once. One setImmediate turn before the decision lets rejections queued by the settling tick arrive first. It is a single turn, not a timer. A shared set of absorbed errors stops overlapping launches from raising each other's orphans. The listener is removed on every path. Add child-process tests that drive the built provider through its launch seam, since Vitest's worker has its own unhandledRejection listener. 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
|
Thanks, Greptile. Both points were right.
I can't fix it at the source. The code that makes them is not ours. 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. The earlier implementation suppressed errors by Playwright stack text alone. The current path absorbs a rejection only when its message repeats a captured launch failure; unrelated errors are forwarded. The shared listener records each rejected promise with the launch scopes that were active when it arrived, and forwards through external listeners without entering its own holding map again. Existing process-boundary regressions retain unrelated-error and real failing-launch cases. Source fix: ab090f3. Tests and checks were skipped at the user's explicit request; this assessment is based on source inspection. Per-launch listeners replayed the same rejected promises into one another, multiplying retained errors. There is now one listener and one promise-indexed holding map. Each event snapshots its candidate launch owners; a settling scope consumes its own failures or releases its candidacy, and an unmatched rejection is forwarded once after its candidates settle. The regression source checks one listener and exactly three original orphan events across a failure overlapping four successful launches. Source fix: ab090f3. Tests and checks were skipped at the user's explicit request; this assessment is based on source inspection. The fake application proves launch settlement but deliberately has no owned process PID, so capture success was the wrong assertion. The regression now expects capture refusal for those four successful launches and specifically checks process_ownership_unavailable; the failing launch retains its alpha failure cause. The one-listener and exactly-three-original-orphan assertions remain, so rejection ownership coverage is preserved rather than weakened. Source fix: ab090f3. Tests and checks were skipped at the user's explicit request; this assessment is based on source inspection. |
* fix(comparison): preserve incomplete function call evidence Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty. Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls. * fix(comparison): recheck historical calls-only changes --------- Co-authored-by: morluto <[email protected]>
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
TL;DR: morluto's fixes work. On Linux, the five test files pass on Node 22, 24 and 26, a bad Results (Linux, head 3ca7237)The head moved from 2b8b0f1 to 3ca7237 while I tested. No PR file changed. Every check gave the same result on both.
Greptile: "macOS checks time out"It was valid. At a69f3ca the test child had 60 seconds and Vitest had 30. A cold Swift build can take 88 seconds. Commit e1579ec raised them to 150 and 180 seconds. I faked a 35 second setup step on Linux. The old file failed at 30 seconds. The current file passed. So I add no change. Each of the 13 tests takes under 0.7 seconds on Linux. Not run
Thanks, morluto, for these fixes
Commandsnpm ci && npm run build && npm run test:prepare
npm run test:focused -- \
tests/acceptance/applications/electronInvalidPaths.test.ts \
src/browser/PlaywrightElectronActiveProvider.test.ts \
tests/acceptance/applications/electronBlankPathCli.test.ts \
tests/boundary/mcp/electronMcp.test.ts \
tests/boundary/process/electronLaunchRejections.test.ts
node scripts/rea.mjs capture-electron-scenario input.json --format jsonThe input file holds For the MCP check, a stdio client called For the slow setup, I ran the test file with Test setup🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
The test that runs an executable which exits at once builds the Swift ownership helper twice on macOS: in the CLI process, and again in the MCP server process on its first tool call that prepares. A cold Swift cache can spend up to 120 seconds on a build. The test had only the 30 second default. Give the test 180 seconds, as e1579ec did for electronLaunchRejections.test.ts and 65a809a did for webSourceLocationCli.test.ts. cli.run has no deadline of its own, so it needs no timeoutMs. 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
|
Follow-up on the macOS timeout note. The early-exit test in Checked on Linux only. The file passes on Node 22, 24 and 26. A fake 35 second setup step fails the old test and passes the new one. The MCP client still limits each call to 60 seconds. This file cannot change that. 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
CI follow-up pushed in 6ab231c. The failed source tests used a PowerPC installation fixture without the required application.java.min; the failed shard inherited GITHUB_STEP_SUMMARY, diverting fixture report output from stdout. The fixes declare the Java bounds and isolate fixture publication/group-classification environment. All 18 affected tests pass locally with CI-like environment variables set; check:fast passes. Current-head hosted CI is still being monitored; no checks or assertions were disabled. |
TL;DR: A bad
executable_pathcould kill the whole REA process. Now a file you can't run is refused up front. A launch that fails gets a normal error, and the server keeps running. I tested this on Linux only.Summary
Refs #2269. I tested on Linux only, so this does not close the issue.
capture_electron_scenariocould end the whole process. In MCP the server exited and the client sawConnection closed. All retained Evidence went with it. In the CLI there was a Node stack trace and no JSON.This PR does two things. It refuses an
executable_paththat is not an executable file, before any launch. It also turns a failed launch into a typedexecution_failureinstead of a crash.Problem and expected behavior
Playwright starts four promises in
electron.launch(). Each waits for output. It awaits only one. When the child exits or the launch times out, all four reject. Nobody awaits the other three. They become unhandled rejections, and Node ends the process.I checked this with a short script that calls
_electron.launchdirectly. For an executable that exits at once, threeunhandledRejectionevents fired about 2 ms before thecatchran. A launch that timed out showed the same shape, with Playwright's ownTimeoutError.On Linux, the smallest trigger is a file with the execute bit that never prints
Debugger listening on. Three such files crashed the process:exit 0A text file without the execute bit did not crash on Linux. The spawn fails with
EACCES, and Playwright rejects cleanly. That case already returnedexecution_failure. On Windows the launch goes through a shell, so any file can reach the crash path. I could not test Windows.Expected: a typed error, a live server, and Evidence that survives.
Change and scope
Two small changes, one at each boundary.
src/application/javascript/ElectronActiveObservationService.tschecks the resolvedexecutable_pathwhile paths are canonicalized. It must be a regular file. On non-Windows hosts it must also passaccess(X_OK). A failure is aninvalid_requestwithissues[0].path = ["executable_path"]. It is the same shape as the unresolved-path issues, and it joins the same list.src/browser/PlaywrightElectronActiveProvider.tswraps only thelaunchcall incontainLaunchRejections. While the call runs, it listens forunhandledRejection. A rejection that does not come from Playwright is re-thrown at once. A Playwright rejection is held until the call settles. If the launch failed, a held rejection is dropped only when its message is part of the launch's own error. Every other held rejection is raised again, so the process still fails. If the launch worked, all held rejections are raised again. The listener is removed on every path. The real error still reaches the existingcatchand becomes the usual typed failure.Not included:
.cmdshim can launch there, and I cannot test PE rules.Closed PR #2501 checked a Windows PE header inside
canonicalPaths. That function is gone from main. It did not touch the Playwright rejection. The commit that closed #2272 says this crash is separate.Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the final review checklist
unchecked. Maintainers can help resolve open questions.
This is a fix inside existing limits. It adds no new capability. A scope decision is not applicable. See the contribution scope.
Contract and boundary impact
invalid_requestinstead ofexecution_failure. Both codes already exist.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
The only new file calls are
statandaccesson the path the caller chose.Evidence and regression coverage
The evidence is executed on Linux. It is not source-derived.
tests/acceptance/applications/electronInvalidPaths.test.ts, and eleven in the newtests/boundary/process/electronLaunchRejections.test.ts. The first two are unchanged. One covers a mode 644 file through CLI and MCP. The other covers an executable that exits at once, through CLI and MCP. It checks that the server survives. It checks thatbinary_sessionworks. It checks thatget_evidence_bundlereturns the same Evidence id. The new file runs the built provider in a child process. It checks that an unrelated rejection still ends the process. It checks that the listener is gone after a launch fails or works. More cases test two launches at once.exit 0script ended the MCP server. The client sawConnection closed. The server printedError: Process failed to launch!fromelectron.js:247. The sleeping script ended the CLI after about 61 s withTimeoutErrorfromprogress.js:86. The new tests fail on main under Node 22, 24 and 26.unhandledRejectionlistener. Most use a fake launch. Two use a real Playwright launch of a script that exits at once. The overlapping cases use fake launches only.Output after the fix, for the mode 644 text file:
{"error":"Electron analysis failed","code":"invalid_request","details":{"operation":"capture_electron_scenario","issues":[{"path":["executable_path"],"reason":"invalid_value","message":"executable_path <file> is not an executable file: EACCES: permission denied, access '<file>'"}]}}For the script that exits at once, the exit code is 1 and the code is
execution_failure. The diagnostics sayProcess failed to launch!. The MCP server stays up.For evidence-bearing changes:
Validation performed
npm run test:focused -- tests/acceptance/applications/electronInvalidPaths.test.ts src/browser/PlaywrightElectronActiveProvider.test.ts tests/acceptance/applications/electronBlankPathCli.test.ts tests/boundary/mcp/electronMcp.test.ts tests/boundary/process/electronLaunchRejections.test.tson Node 22.23.1, 24.18.0 and 26.11.1: 5 files and 25 tests passed on each.npm run test:focusedon the 22 test files with "electron" in the name, on Node 24: 342 tests passed.npm run check:faston Node 24: passed.npm run verify:test-discovery: all 1039 test files found once.oxfmt --checkon the four changed files: passed..har, a.txt, a script that exits, a mode 755 text file and a script that sleeps. After the fix, none ended the process. After the revision I reran three of them through the CLI. They were the script that exits at once, the mode 644 file, and a script that sleeps 300 s. The last one hits the real 60 s timeout. None ended the process. I did not rerun the MCP checks on the revised code.Not run: the full suite,
npm run check:pr,npm run docs:check,npm run verify:package, Windows, macOS, and a real Electron launch.Compatibility, safety, and release
execution_failure. It now givesinvalid_request.Before merge
type(scope): outcome.🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊