fix(core): bind ULID to Web Crypto so the MV3 service worker can load (#57)#58
Merged
Conversation
…#57) ulid() with no PRNG ran the library's env auto-detection, which throws 'secure crypto unusable, insecure Math.random not allowed' in the crxjs MV3 service-worker context — crashing SW registration. The whole background (reconcile, native-tree listeners, poll) never ran; only the popup worked. Bind the PRNG explicitly to crypto.getRandomValues via ulid's factory(), which is available in the SW, extension pages, the web UI, and Node 19+. +1 regression test asserting newUlid uses Web Crypto and doesn't hit the throw path. Closes #57 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 19, 2026
Closed
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.
Closes #57.
Critical: the Chrome MV3 service worker has been failing to register ("service worker (Inactive)", secure crypto unusable, insecure Math.random not allowed), so the entire background never ran — native-tree sync, cold-start reconcile, and the poll. Only the popup worked.
Cause:
newUlid()calledulid()with no PRNG → the library's env auto-detection throws under crxjs MV3 SW bundling at module load →reconcile.ts/listeners.tsimport it → SW crash.Fix: bind ULID to
crypto.getRandomValuesviafactory(). +1 regression test.Follow-up (separate issue/PR): add a Playwright e2e that loads the unpacked extension and asserts the SW registers with no error, so a dead SW fails CI.
core: 82 → 83 tests; typecheck + chrome/firefox builds clean.
🤖 Generated with Claude Code