Skip to content

feat: disconnect idle existing Firefox sessions - #179

Open
f3tchcodes wants to merge 2 commits into
mozilla:mainfrom
f3tchcodes:feat/idle-existing-firefox
Open

feat: disconnect idle existing Firefox sessions#179
f3tchcodes wants to merge 2 commits into
mozilla:mainfrom
f3tchcodes:feat/idle-existing-firefox

Conversation

@f3tchcodes

@f3tchcodes f3tchcodes commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Bugzilla: Bug 2066912

This change disconnects from an existing Firefox instance after 30 minutes of inactivity when using --connect-existing. The Firefox process itself stays open, and the MCP reconnects to the same instance on the next tool call. The idle timeout is reset by new tool activity and does not run while a tool call is still in progress.

I tested it manually by:

  1. connecting to an existing Firefox and running a tool via inspector
  2. waiting for the idle timeout and confirming geckodriver exits while Firefox stays open (you can refer to background processes for this)
  3. calling another tool and confirming the MCP reconnects to the Firefox instance (it should reconnect to that same instance, but that specifically is not confirmed yet)

@juliandescottes

Copy link
Copy Markdown
Collaborator

Sorry about the delay for the review here, I need some more focused time to test this than for the usual PRs, but I will take a look today.

@f3tchcodes

Copy link
Copy Markdown
Contributor Author

No worries, take your time.

@f3tchcodes

Copy link
Copy Markdown
Contributor Author

Just a small note for manual testing: the idle timeout can be temporarily changed to 10 seconds locally from src/firefox/idle-connection.ts, so the disconnect/reconnect cycle can be tested without waiting 30 minutes.

@juliandescottes juliandescottes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, I would like to see a simpler implementation. The idle-connection wrapper is a bit too complex for something which only matters in one specific scenario.

I suggest to drop this wrapper and instead create a timer/promise/counter inline in CallToolRequestSchema. Downside is that we can't easily cover that with tests, but I think the simplification makes it worth this.

@f3tchcodes

Copy link
Copy Markdown
Contributor Author

Alright, I'll rewrite and make it a simpler.

@f3tchcodes
f3tchcodes force-pushed the feat/idle-existing-firefox branch 3 times, most recently from 8a5c721 to 398bab7 Compare September 12, 2026 09:30
@f3tchcodes
f3tchcodes force-pushed the feat/idle-existing-firefox branch from 398bab7 to 417cc13 Compare September 12, 2026 09:34
@f3tchcodes

Copy link
Copy Markdown
Contributor Author

I have made the requested changes!

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