client: path-scope vault BroadcastChannel under isolate_storage#69
Merged
Conversation
new BroadcastChannel('websh_vault') used a static name across the
origin, so under isolate_storage two tabs at /team-a/ and /team-b/
shared the channel. A sign-out on /team-a/ would broadcast into
/team-b/, where the handler tears down live vault panes, invalidates
the in-memory caches, and sets _vaultRecentlySignedOut — blocking
the unrelated /team-b/ tenant's active session and refusing
subsequent saves until doConnect clears the flag.
Fix: include storagePrefix in the channel name. Module init opens
'websh_vault:' (storagePrefix='' until /api/config resolves), then
loadServerConfig re-inits with the now-known prefix — a no-op when
isolate_storage is off, a distinct channel when it's on. _initVault-
Broadcast became idempotent on name match so the bfcache pageshow
restore and the loadServerConfig call don't double-mint.
Tests: two new regressions pin the contract — the channel name
includes the URL path under isolate_storage, and a cross-path
sibling's signed_out does NOT reach this tab's handler (with a
same-path sanity-check that scoping is the discriminator, not a
global block). Existing same-channel sign-out tests updated to use
the new name. 497 frontend tests pass (was 490).
Code-review nit: align the path-scoped channel-name shape with the existing storageKey() / _idbScopedKey() convention (prefix-then-name). The new shape is 'websh_vault' under the empty default and '/team-a/websh_vault' under isolate_storage — equivalent uniqueness, consistent with the rest of the codebase. Side benefit: the empty-prefix name reverts to plain 'websh_vault', so the two existing same-channel tests in this file don't need their mock-name strings updated.
This was referenced May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
new BroadcastChannel('websh_vault')used a static name across the origin, so underisolate_storagetwo tabs at different URL paths shared the channel. A sign-out on/team-a/would reach/team-b/, whose handler tears down live vault panes, invalidates the in-memory caches, and sets_vaultRecentlySignedOut— blocking the unrelated tenant's active session and refusing subsequent saves untildoConnectclears the flag.User-visible impact (under
isolate_storage): tenant on one path signs out → unrelated tenant's vault panes drop with a "Vault key missing" reconnect bar, and any in-flight save in their tab silently aborts.Fix
Include
storagePrefixin the channel name. Module init opens'websh_vault:'(storagePrefix='' before/api/configresolves), thenloadServerConfigre-inits with the now-known prefix — a no-op whenisolate_storageis off, a distinct channel when it's on._initVaultBroadcastbecame idempotent on name match so the bfcachepageshowrestore and theloadServerConfigcall don't double-mint.The eager module-init open is kept so the brief boot window still catches sign-outs (with the default name); the re-init upgrades to the path-scoped name as soon as the config is in.
Tests
Two new regressions:
vault BroadcastChannel name is path-scoped under isolate_storage— asserts module-init opens'websh_vault:'andloadServerConfigre-opens with'websh_vault:/team-a/'.sibling tab on a different path does NOT trigger sign-out handler— uses a name-filteringBroadcastChannelmock (more faithful to real BC semantics than the permissive mock used in the existing tests) and asserts the cross-pathsigned_outleaves_idbHasKeyCacheand_vaultRecentlySignedOutuntouched. Same-path sanity-check confirms scoping is the discriminator, not a global block.Two existing same-channel tests updated to use the new
'websh_vault:'name (storagePrefix empty under default config). 497 frontend tests pass (was 490 before this PR).Test plan
cd tests/frontend && node test_connect.js— 497 / 0python3 test_server.py -q— 420 / 0 (unchanged; client-only fix)isolate_storage, sign out on one, verify other tenant's session stays aliveRefs #67 (follow-up from holistic review).