Skip to content

fix(web): use static import for vault store in __E2E helpers#303

Merged
FSM1 merged 1 commit into
mainfrom
fix/e2e-static-import-race
Mar 21, 2026
Merged

fix(web): use static import for vault store in __E2E helpers#303
FSM1 merged 1 commit into
mainfrom
fix/e2e-static-import-race

Conversation

@FSM1

@FSM1 FSM1 commented Mar 21, 2026

Copy link
Copy Markdown
Owner

Summary

The dynamic import('./stores/vault.store').then() in main.tsx created a race condition — window.__E2E was undefined when conflict-detection tests called page.evaluate() in beforeAll because the async import hadn't resolved yet.

Switched to a static import. Vite dead-code-eliminates the entire VITE_E2E block (including the unused import) in production builds where the flag isn't set.

Test plan

  • Conflict-detection E2E tests pass (__E2E.getAccessToken() no longer throws)
  • Production build doesn't include vault store (verify with VITE_E2E unset)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Updated internal import handling for improved initialization flow. No user-facing changes.

The dynamic import().then() created a race condition — __E2E was
undefined when conflict-detection tests read it because the async
import hadn't resolved yet. Switch to static import since Vite
dead-code-eliminates the entire VITE_E2E block (including unused
imports) in production builds anyway.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: a1b1e020ce59
@coderabbitai

coderabbitai Bot commented Mar 21, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

The change converts a dynamic import of useVaultStore inside an E2E conditional block to a static top-level import while maintaining the runtime guard. This shifts initialization from asynchronous callback-based to synchronous execution when the VITE_E2E condition is met.

Changes

Cohort / File(s) Summary
E2E Store Initialization
apps/web/src/main.tsx
Replaced conditional dynamic import with static top-level useVaultStore import; converted async Promise-based window.__E2E initialization to synchronous assignment while preserving the VITE_E2E runtime guard.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: replacing a dynamic import with a static import for the vault store in E2E helpers, which is the core fix addressing the race condition issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/e2e-static-import-race

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@FSM1 FSM1 enabled auto-merge (squash) March 21, 2026 02:55
@FSM1 FSM1 merged commit a09b502 into main Mar 21, 2026
23 of 24 checks passed
@FSM1 FSM1 deleted the fix/e2e-static-import-race branch March 21, 2026 02:57
This was referenced Mar 21, 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.

1 participant