Repository navigation
fix: build persistent action ids without crypto.randomUUID - #101
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Strengthen the native UUID test by asserting the delegated sentinel value.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes persistent action IDs on plain HTTP origins by adding a secure UUID fallback and sharing it across action and file handling.
Changes:
- Added native/fallback UUID generation.
- Updated persistent actions and multipart boundaries.
- Added UUID and regression tests.
File summaries
| File | Summary |
|---|---|
src/random-uuid.test.ts |
Tests UUID behavior and persistence regression. |
src/persistent-actions.ts |
Uses the shared UUID generator for action IDs. |
src/index.test.ts |
Registers the new test suite. |
src/functions.ts |
Adds native/fallback UUID generation. |
src/files.ts |
Uses UUIDs for multipart boundaries. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
/review AI review started. |
Advanced AI Review
Click to expand reviewReview:
|
There was a problem hiding this comment.
🟡 Changes recommended
The regression test does not exercise the fallback path used by PersistentAction.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
One or more issues must be addressed before approval.
Review details
Suppressed comments (1)
src/random-uuid.test.ts:60
- This test imports
PersistentActionbeforewithRandomUUIDremoves the native method, sopersistent-actions.jshas already cached the native branch. The constructor assertion therefore never exercises the plain-HTTP path that this PR fixes; the fallback tests only call a freshly importedfunctions.jsexport. Please load the persistent-actions module after hidingrandomUUID(or otherwise inject the fallback) and construct the action in that state.
it('gives a persistent action a usable id', () => {
assert.match(new PersistentAction(['log', 'hello']).id, V4)
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
Closes #100
Related okTurtles/todomvc#5
PersistentActionbuilt its id withcrypto.randomUUID, which browsers onlygive you on https and localhost, so the first enqueue on any other plain http
origin threw and the action was lost.
Adds
randomUUIDtofunctions.ts: native when available, otherwise builtfrom
getRandomValues, which is there on every origin.persistent-actions.tsand
files.tsboth use it now, so the fallback lives in one place instead ofonly in
files.ts.The
files.tsboundary keeps the native path it had. Its fallback changes from36
Math.randomletters to the UUID, which is still a valid multipartboundary, and it no longer reads
self, which is undefined in Node. I alsodropped the TODO above it about
randomUUIDbreaking the Cypress tests, sincethat code already called native
randomUUIDwhenever it existed and thischange keeps that path the same. Say the word if you want it back.
Testing
All tests are passing. The new ones cover the native path, the fallback,
uniqueness, and building a
PersistentActionwithrandomUUIDhidden, whichis the reported symptom. Taking the fallback back out makes that last one fail
with the error from the issue.
Also tested against TodoMVC, which is where we hit this. I packed this branch,
installed it there, and removed TodoMVC's own workaround so nothing but this
fix could do the work. On a plain http LAN address (
isSecureContextfalse,no
randomUUIDfrom the browser) signup worked, a write made while the serverwas unreachable went into the queue with a real UUID id, and it landed once the
server was back. TodoMVC's own suite passed too.
AI Usage: Claude Opus 5 Max
Self review: Approved