Skip to content

Remove unnecessary timestamped bridge filenames and fix concurrency for different games#35

Merged
pardeike merged 2 commits intomainfrom
copilot/fix-34
Sep 14, 2025
Merged

Remove unnecessary timestamped bridge filenames and fix concurrency for different games#35
pardeike merged 2 commits intomainfrom
copilot/fix-34

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 14, 2025

This PR addresses the concurrency concerns raised in issue #34 by fixing the fundamental misunderstanding about what type of concurrency should be supported.

Problem

The original code was designed to handle concurrent launches of the same game using timestamped filenames like bridge-{timestamp}.json. However, the actual requirement was to support concurrent launches of different games (e.g., game X and game Y simultaneously). The concern was that ENV variables might not be properly isolated between processes, potentially causing cross-contamination.

Solution

1. Removed Unnecessary Timestamped Filenames

Before:

~/.gabs/minecraft/bridge-1757863951223043470.json
~/.gabs/minecraft/bridge-1757863951222710067.json  # Multiple files for same game
~/.gabs/minecraft/bridge.json                      # Backward compatibility file

After:

~/.gabs/minecraft/bridge.json   # One file per game
~/.gabs/rimworld/bridge.json    # Each game has its own directory
~/.gabs/terraria/bridge.json

2. Verified ENV Variable Isolation

Added comprehensive tests to verify that Go's exec.Command provides proper environment variable isolation:

// Each concurrent game process receives its own ENV variables
game1: Output=GAME:game1 PORT:61886 TOKEN:11dee295...
game2: Output=GAME:game2 PORT:60031 TOKEN:222ed984...
// No cross-contamination between processes

3. Updated Concurrency Tests

Changed the concurrency test from testing multiple launches of the same game to testing concurrent launches of different games, which is the actual supported use case:

// OLD: 10 concurrent launches of "minecraft" 
// NEW: 10 different games launched concurrently
gameNames := []string{"minecraft", "rimworld", "terraria", "stardew", "factorio", ...}

Key Findings

  1. ENV variable isolation is guaranteed by Go's exec.Command - each process gets its own environment
  2. No serialization needed - concurrent launches of different games are completely safe
  3. Simpler file structure - each game gets exactly one bridge.json in its own directory
  4. No breaking changes - all existing functionality is preserved

Test Results

  • ✅ All existing tests pass
  • ✅ New concurrency test verifies different games can launch simultaneously
  • ✅ New ENV isolation test confirms no cross-contamination
  • ✅ Application builds and runs correctly

The code now properly supports concurrent launching of different games while removing unnecessary complexity that was designed for an unsupported use case.

Fixes #34.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: pardeike <853584+pardeike@users.noreply.github.com>
Copilot AI changed the title [WIP] Verify concurrency fix Remove unnecessary timestamped bridge filenames and fix concurrency for different games Sep 14, 2025
Copilot AI requested a review from pardeike September 14, 2025 15:39
@pardeike pardeike marked this pull request as ready for review September 14, 2025 15:41
@pardeike pardeike merged commit 709939d into main Sep 14, 2025
2 checks passed
@pardeike pardeike deleted the copilot/fix-34 branch September 14, 2025 15:41
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.

Verify concurrency fix

2 participants