Skip to content

fix: concurrency races in WASM init + grammar loading, transaction safety - #77

Merged
HrushiBorhade merged 1 commit into
mainfrom
phase-2/review-fixes
Mar 24, 2026
Merged

HrushiBorhade merged 1 commit into
mainfrom
phase-2/review-fixes

Conversation

@HrushiBorhade

Copy link
Copy Markdown
Owner

Summary

Fixes 4 issues found during code review of Phase 2 Steps 1+2.

Fixes

Issue Severity Fix
ensureInit race — concurrent calls double-initialize WASM Critical Promise-as-lock pattern: first caller creates promise, others await it
getLanguage race — concurrent callers load same grammar twice Important Same promise-as-lock: languageLoading Map tracks in-flight loads
SqliteSyncStorage.transaction — ROLLBACK fails if DB closed Important Wrapped ROLLBACK in try/catch to handle closed connections
persistMerkleState — unnecessary read-back of just-written hashes Important Use in-memory fileHashMap filtered by successfulFiles instead of N storage reads

Test plan

  • All 32 chunker tests pass
  • All 10 sync tests pass
  • pnpm typecheck passes
  • pnpm format:check passes

…fety

- ensureInit: promise-as-lock pattern prevents concurrent WASM double-init
- getLanguage: promise-as-lock prevents duplicate grammar loading for same language
- SqliteSyncStorage.transaction: protected ROLLBACK in catch to handle closed connections
- persistMerkleState: removed unnecessary read-back of just-written hashes
@HrushiBorhade HrushiBorhade added the phase-2 Phase 2: Indexing Pipeline label Mar 24, 2026

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@vercel

vercel Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
code-indexer-web Ready Ready Preview, Comment Mar 24, 2026 2:17pm

@HrushiBorhade
HrushiBorhade merged commit 0fd1865 into main Mar 24, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — f43d0904 Deployed Mar 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase-2 Phase 2: Indexing Pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant