Skip to content

fix: worker-service missing sqlite/SessionStore.js + observations/files.js (#3092)#3102

Open
bionicbutterfly13 wants to merge 1 commit into
thedotmack:mainfrom
bionicbutterfly13:fix/worker-lazy-sqlite-modules-missing-from-bundle
Open

fix: worker-service missing sqlite/SessionStore.js + observations/files.js (#3092)#3102
bionicbutterfly13 wants to merge 1 commit into
thedotmack:mainfrom
bionicbutterfly13:fix/worker-lazy-sqlite-modules-missing-from-bundle

Conversation

@bionicbutterfly13

Copy link
Copy Markdown

Summary

Fixes Bug 1 from #3092: the Chroma backfill pipeline failed on every worker startup with Cannot find module '../sqlite/SessionStore.js'.

ChromaSync.ts loads SessionStore and parseFileList through a runtime createRequire(import.meta.url)(...) call instead of a static import, intentionally, so the cmem-sdk (tsup) build doesn't follow them and drag bun:sqlite into SDK consumers. But esbuild's worker-service bundle in scripts/build-hooks.js doesn't follow that same indirection either — it only inlines modules reached through a literal require(...) call, not one made via a locally-created require reference — so worker-service.cjs shipped without either module. Every worker startup logged Backfill failed (non-blocking) from the resulting Cannot find module error, and Chroma vector-search backfill silently never ran.

  • scripts/build-hooks.js: after the existing worker-service.cjs build step, add a build pass that emits both modules as loose files next to the bundle (plugin/sqlite/SessionStore.js, plugin/sqlite/observations/files.js), matching the relative path ChromaSync.ts's lazy require() expects at runtime.
  • package.json: add plugin/sqlite to the npm files whitelist — without this the fix builds and tests clean locally but the published package still wouldn't ship the emitted files.
  • tests/worker-service-lazy-sqlite-modules.test.ts: regression test that resolves both modules the same way ChromaSync.ts does at runtime. Verified locally that it reproduces the exact #3092 error when the fix is reverted, and passes with it applied.
  • CHANGELOG.md: [Unreleased] entry per the contribution guidelines in docs/public/development.mdx.

Out of scope: Bug 2 from #3092 (the .install-version marker / "runtime not yet set up" message) is a separate, architecturally distinct issue — it's about the Claude Code marketplace install path never invoking the npx installer that writes that marker, not a build-pipeline gap. Left for a follow-up so this PR stays scoped to one concern.

Test plan

  • bun test tests/worker-service-lazy-sqlite-modules.test.ts — 4/4 pass with the fix applied
  • Confirmed the test fails with the exact #3092 error text when plugin/sqlite/ is removed (proves it's a real regression guard, not a tautology)
  • Verified via isolated npm pack --dry-run --json that the new plugin/sqlite files entry recursively packs the nested plugin/sqlite/observations/files.js
  • Full npm run build && npm run typecheck && bun test — not run locally (heavy toolchain: tree-sitter-cli, onnxruntime-node, Chroma); relying on this repo's own CI (.github/workflows/ci.yml) to run these on the PR

…es.js (thedotmack#3092)

ChromaSync.ts loads SessionStore and parseFileList through a runtime
createRequire(import.meta.url)(...) call instead of a static import, so
tsup's cmem-sdk build doesn't follow them and drag bun:sqlite into SDK
consumers. But esbuild's worker-service bundle doesn't follow that same
indirection either, so worker-service.cjs shipped without these two
modules entirely — every worker startup logged "Backfill failed
(non-blocking)" from a Cannot find module '../sqlite/SessionStore.js'
error, and Chroma vector-search backfill silently never ran.

- scripts/build-hooks.js: emit both modules as loose files next to the
  worker bundle (plugin/sqlite/SessionStore.js,
  plugin/sqlite/observations/files.js)
- package.json: add plugin/sqlite to the npm files whitelist so the
  published package actually ships them
- tests/worker-service-lazy-sqlite-modules.test.ts: regression test
  asserting both modules are emitted and resolve the same way
  ChromaSync.ts requires them at runtime
- CHANGELOG.md: Unreleased entry per contribution guidelines
@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes missing lazy SQLite modules in the worker package. The main changes are:

  • Adds a worker build step that emits plugin/sqlite/SessionStore.js and plugin/sqlite/observations/files.js beside worker-service.cjs.
  • Adds plugin/sqlite to the npm package file whitelist.
  • Adds tests for the runtime createRequire resolution path used by ChromaSync.ts.
  • Documents the worker Chroma backfill fix in CHANGELOG.md.

Confidence Score: 5/5

The changes are narrowly scoped to packaging the lazy-loaded SQLite worker modules and adding a regression test for the runtime resolution path.

No code issues were identified in the reviewed changes, and the added test directly covers the failure mode described by the package build fix.

T-Rex T-Rex Logs

What T-Rex did

  • The lazy-SQLite build-hooks flow was executed, emitting SessionStore.js and observations/files.js, enabling Bun createRequire to load both exports and allowing parseFileList checks to pass.
  • The npm-pack-sqlite packaging step was run; before state showed the files were not parsed as present, and after state showed both files parsed as present.
  • The worker-service-lazy-sqlite-modules tests were run; initially they failed due to missing modules, and after emitting the lazy SQLite modules the tests passed (4 pass, 0 fail).

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "fix: worker-service missing sqlite/Sessi..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

T-Rex pricing update — T-Rex was free through June 2026. Effective July 1, 2026, T-Rex adds 2 credits on top of the standard 1-credit review (3 total). T-Rex settings

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