Skip to content

fix(cli): exit daemon when extension connection fails#40328

Merged
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:fix-cli-daemon-leak-on-extension-reject
Apr 21, 2026
Merged

fix(cli): exit daemon when extension connection fails#40328
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:fix-cli-daemon-leak-on-extension-reject

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented Apr 21, 2026

Summary

  • Daemon process.exit(1) after logging startup failure (the stdout pipe libuv handle would otherwise keep it alive forever).
  • Extension factory closes the CDP relay + http server on failure.
  • Connect UI sends rejectConnection to the background so the pending relay socket is closed and the daemon sees the disconnect.
  • Session.startDaemon includes the daemon pid in rejection errors so callers (and the new tests) can verify the daemon actually exited.

The cli daemon process leaked when the user rejected or closed the
extension connect tab. The HTTP server, websocket relay, and stdio pipes
all kept the event loop alive after createBrowserWithInfo threw.

- Daemon process.exits after logging the startup error.
- Extension factory closes the relay + http server on failure.
- Connect UI tells the background to drop the pending relay socket on
  reject so the daemon sees the disconnect.
- session.startDaemon includes the daemon pid in rejection errors so
  callers (and tests) can verify the daemon actually exited.
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

6434 passed, 976 skipped


Merge workflow run.

const errLogContent = fs.readFileSync(errLog, 'utf-8');
const message = `Daemon process exited with code ${code}` + (errLogContent ? '\n' + errLogContent : '');
reject(new Error(message));
rejectWithPid(reject, `Daemon process exited with code ${code}` + (errLogContent ? '\n' + errLogContent : ''));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does not look necessary?

@yury-s yury-s merged commit 5e7e2e2 into microsoft:main Apr 21, 2026
11 checks passed
@yury-s yury-s deleted the fix-cli-daemon-leak-on-extension-reject branch April 21, 2026 06:34
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.

2 participants