Skip to content

fix: use a lock to ensure only need to run tunnel just in case multiple go…#5885

Merged
michaelneale merged 1 commit intomainfrom
micn/only-tunnel-once
Dec 1, 2025
Merged

fix: use a lock to ensure only need to run tunnel just in case multiple go…#5885
michaelneale merged 1 commit intomainfrom
micn/only-tunnel-once

Conversation

@michaelneale
Copy link
Collaborator

@michaelneale michaelneale commented Nov 26, 2025

there can be multiple goosed but should only be one tunnel running.

small one - would rather not need to do this, but as things are now, we let many goosed fly (pun intended) so as this is in process, don't really want to double up (not sure what would happen - probably nothing functionally good!)

Copilot AI review requested due to automatic review settings November 26, 2025 05:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements file-based locking to ensure only one tunnel instance runs across multiple goose-server processes. The fix uses the fs2 crate for cross-process exclusive file locks, preventing duplicate tunnel instances from starting simultaneously.

Key changes:

  • Added fs2 dependency for cross-process file locking
  • Implemented lock acquisition/release functions with PID tracking
  • Integrated lock into TunnelManager lifecycle (acquire on start, release on stop/error)
  • Updated status reporting to detect tunnels running in other instances
  • Changed auto-start error logging from error to info level when lock is already held

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
crates/goose-server/src/tunnel/mod.rs Core implementation: adds lock acquisition/checking functions, integrates file lock into TunnelManager struct, updates start/stop to acquire/release lock, modifies status reporting to detect tunnels in other instances
crates/goose-server/Cargo.toml Adds fs2 0.4.3 dependency for file locking
Cargo.lock Updates lock file with fs2 dependency

Copy link
Collaborator

@alexhancock alexhancock left a comment

Choose a reason for hiding this comment

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

LGTM if using a file is easiest!

One Q though: is there anything that already must be in use if the tunnel is active? I see there is a port involved somehow. Could you check if something is already using a known port?

@michaelneale
Copy link
Collaborator Author

@alexhancock no known port - the only port used is randomly assigned for goosed (at the moment) - I guess if that was persisted it could check if it is still active and use that as a lock? (I don't think the tunnel itself uses a port - it just internally passes from websocket to the temporary port goosed is using).

@michaelneale michaelneale merged commit 03fb892 into main Dec 1, 2025
22 checks passed
@michaelneale michaelneale deleted the micn/only-tunnel-once branch December 1, 2025 22:59
katzdave added a commit that referenced this pull request Dec 1, 2025
…nses-streaming

* 'main' of github.com:block/goose:
  docs: promote planning guide (#5934)
  fix: use a lock to ensure only need to run tunnel just in case multiple go… (#5885)
  Feat: Added custom headers and toggle keyring CLI options (#5017)
@alexhancock
Copy link
Collaborator

@alexhancock no known port - the only port used is randomly assigned for goosed (at the moment) - I guess if that was persisted it could check if it is still active and use that as a lock? (I don't think the tunnel itself uses a port - it just internally passes from websocket to the temporary port goosed is using).

I figured as much - file based seems fine!

zanesq added a commit that referenced this pull request Dec 2, 2025
* 'main' of github.com:block/goose:
  chore: upgrade npm packages (#5951)
  feat: ActionRequired (#5897)
  feat(acp): support loading sessions in acp (#5942)
  docs: add videos to multi-model page (#5938)
  docs: promote planning guide (#5934)
  fix: use a lock to ensure only need to run tunnel just in case multiple go… (#5885)
zanesq added a commit that referenced this pull request Dec 2, 2025
…0-5147

* 'main' of github.com:block/goose: (243 commits)
  chore: upgrade npm packages (#5951)
  feat: ActionRequired (#5897)
  feat(acp): support loading sessions in acp (#5942)
  docs: add videos to multi-model page (#5938)
  docs: promote planning guide (#5934)
  fix: use a lock to ensure only need to run tunnel just in case multiple go… (#5885)
  Feat: Added custom headers and toggle keyring CLI options (#5017)
  Feat/automatic update installation (#5345)
  fix: Added "Merged consecutive assistant messages" to the acceptable issues for moim injection check (#5933)
  fix: anthropic provider model fetching (#5932)
  [MCP-UI] add CSP for images to proxy HTML (#5931)
  fix: correct typo in blog post (AIMDOEL -> AIMODEL) (#5902)
  feat: @goose in terminal (native terminal support) (#5887)
  docs: adding AI-friendly features (#5918)
  Blog/advent of ai announcement (#5917)
  Extension selector behind ALPHA flag (#5892)
  blog: typo fixes (#5896)
  blog: fixing img url (#5895)
  blog: MCPs for Developers (#5884)
  docs: Extension Manager MCP (#5883)
  ...

# Conflicts:
#	crates/goose-server/src/routes/config_management.rs
#	crates/goose/src/providers/mod.rs
#	ui/desktop/openapi.json
#	ui/desktop/src/api/sdk.gen.ts
#	ui/desktop/src/api/types.gen.ts
#	ui/desktop/src/components/ProgressiveMessageList.tsx
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.

3 participants