Skip to content

Atomic cache writes and deduplicate AuthTest on startup#256

Closed
mark-liu wants to merge 1 commit intokorotovsky:masterfrom
mark-liu:upstream-pr/atomic-cache-auth-dedup
Closed

Atomic cache writes and deduplicate AuthTest on startup#256
mark-liu wants to merge 1 commit intokorotovsky:masterfrom
mark-liu:upstream-pr/atomic-cache-auth-dedup

Conversation

@mark-liu
Copy link
Copy Markdown

Fixes #254 and #255.

Two fixes for running multiple MCP server instances concurrently (e.g. Claude Code launching separate instances per workspace):

  • Cache files are now written atomically via write-to-temp-then-rename. Previously os.WriteFile on 300-460MB JSON files could leave partial data visible to concurrent readers.

  • validateAuthAndGetTeamID now returns the full AuthTestResponse which is passed into NewMCPSlackClient, eliminating a redundant AuthTest API call per startup (2 per instance down to 1). Reduces rate limit pressure when multiple instances start simultaneously.

No new dependencies. Backwards compatible — NewMCPSlackClient accepts nil for cachedAuth and falls back to calling AuthTest itself.

Two fixes for running multiple MCP server instances concurrently:

1. Cache files (users, channels) are now written atomically via
   write-to-temp-then-rename. Previously os.WriteFile could leave
   partial 400MB+ JSON files visible to concurrent readers.

2. validateAuthAndGetTeamID now returns the full AuthTestResponse
   which is passed to NewMCPSlackClient, eliminating a redundant
   AuthTest API call per startup (2 per instance down to 1).

Signed-off-by: Mark Liu <mark@prove.com.au>
@mark-liu
Copy link
Copy Markdown
Author

Superseded by #259 (squashed and rebased with #249).

@mark-liu mark-liu closed this Mar 26, 2026
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.

Cache writes are not atomic — concurrent instances can corrupt JSON files

1 participant