Skip to content

[Bug] Session inheritance (inheritSessionFrom) fails on Linux but works on macOS #31

@hydro13

Description

@hydro13

Description

Session inheritance via inheritSessionFrom parameter in /tabs/open works correctly on macOS but fails on Linux. New tabs created with session inheritance end up logged out instead of copying the auth state from the source tab.

Steps to Reproduce

  1. On Linux (Ubuntu 24.04, Wayland):

    • Open Discord and log in (tab-2)
    • Create new tab with session inheritance:
      curl -X POST http://127.0.0.1:8765/tabs/open \
        -H "Authorization: Bearer \$TOKEN" \
        -H "Content-Type: application/json" \
        -d '{"url": "https://discord.com/channels/@me", "inheritSessionFrom": "tab-2"}'
    • Expected: New tab opens logged in
    • Actual: New tab redirects to /login (logged out)
  2. On macOS:

    • Same steps work correctly ✅
    • New tab inherits session and stays logged in

Environment

  • Linux: Ubuntu 24.04 (Wayland), Tandem v0.65.5
  • macOS: Working correctly (reported by user)
  • Both platforms use same partition: persist:tandem

Investigation

The IndexedDB copy appears to complete without errors, but Discord auth state is not properly restored on Linux:

# After session inheritance on Linux:
curl "http://127.0.0.1:8765/devtools/evaluate" \
  -d '{"tabId": "tab-9", "expression": "document.cookie.includes(\\"__dcfduid\\")"}'
# Returns: false (no Discord cookies)

Root Cause Hypothesis

Timing/race condition in src/tabs/manager.ts copyIndexedDbFrom():

await targetWc.executeJavaScript(this.buildIndexedDbRestoreScript(dumpJson));
await targetWc.loadURL(targetUrl);  // <- May start before restore completes on Linux

Linux filesystem I/O may be slower than macOS, causing the loadURL to execute before IndexedDB writes finish.

Possible Fix

Add explicit wait for IndexedDB transaction completion in buildIndexedDbRestoreScript():

// After all database operations
return new Promise(resolve => {
  setTimeout(() => resolve(true), 100);  // Let IndexedDB flush
});

Or use IndexedDB transaction .oncomplete callbacks.

Impact

  • Severity: High - breaks core feature on Linux
  • Workaround: None (users must manually log in to each new tab)
  • Platform: Linux only

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions