Skip to content

fix(eve): send optimistic messages without crypto.randomUUID - #5417

Merged
AndrewBarba merged 1 commit into
e0/repro-5415-non-secure-randomuuidfrom
e0/fix-5415-non-secure-randomuuid
Oct 27, 2026
Merged

AndrewBarba merged 1 commit into
e0/repro-5415-non-secure-randomuuidfrom
e0/fix-5415-non-secure-randomuuid

Conversation

@roboeve

@roboeve roboeve Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5415

Stacked on #5416, which pins the bug as an expected failure.

Summary

Browsers expose crypto.randomUUID only in secure contexts. On a plain-HTTP origin that is not localhost, OptimisticMessageSubmissions.submit() called it directly, so every SessionStore.send() threw TypeError: crypto.randomUUID is not a function before the message POST. This breaks useEveAgent sends in React, Vue, and Svelte for, say, a dev server opened from a phone over a LAN IP.

The id only correlates a local echo with its delivery, so it needs to be unique within the page, not a UUID. This restores what createSubmissionId() did before #4855: use crypto.randomUUID() when the browser exposes it, otherwise a module-level submission_<n> sequence. Secure contexts keep UUIDs, as today.

Regressed in: #4855 (4a4951ef5, first in eve@0.84.0).

Alternative to weigh: the reporter suggested building a UUID v4 from crypto.getRandomValues() for the fallback. That keeps ids unique across page loads, which matters only if an app persists message.id of its own user messages; the sequence matches pre-0.84 behavior with less code.

Validation

  • Repro head (c9adc04f8): sends where crypto.randomUUID is not exposed, as on a plain-HTTP origin fails with TypeError: crypto.randomUUID is not a function at optimistic-message-submissions.ts:26, pinned with it.fails (73 passed | 1 expected fail).
  • Fix head: marker removed; pnpm --filter eve exec vitest run --config vitest.unit.config.ts src/client/session-store.test.ts passes 74/74. The test sends two messages with only getRandomValues on crypto and asserts both POSTs and two distinct echoes.
  • vitest.unit.config.ts over src/client (229 passed) and src/react src/vue src/svelte (86 passed).
  • tsc -p packages/eve/tsconfig.json --noEmit, pnpm guard:invariants, oxfmt --check, and oxlint on the changed files.

Review rating: c1, restores the pre-#4855 fallback with focused proof, but the reviewer may prefer a getRandomValues UUID over the local sequence since the id becomes the public message.id.

Browsers expose crypto.randomUUID only in secure contexts. Restore the local sequence fallback that #4855 dropped so SessionStore.send() works on plain-HTTP origins, and remove the expected-failure marker from the #5415 regression.

Co-authored-by: ruiconti <1834568+ruiconti@users.noreply.github.com>
@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
eve-docs Ready Ready Preview, v0 Oct 27, 2026 4:08am UTC
eve-pkg Ready Ready Preview, v0 Oct 27, 2026 4:08am UTC

@roboeve
roboeve Bot added this pull request to stack #5418 October 27, 2026 04:06
@roboeve roboeve Bot added the c1 Relatively easy review; needs some context or an alternate approach to weigh label Oct 27, 2026
@roboeve
roboeve Bot requested a review from ruiconti October 27, 2026 04:07
@roboeve
roboeve Bot marked this pull request as ready for review October 27, 2026 04:15
@roboeve
roboeve Bot requested a review from a team as a code owner October 27, 2026 04:15
@AndrewBarba
AndrewBarba merged commit ddbe77c into main Oct 27, 2026
160 of 161 checks passed
@AndrewBarba
AndrewBarba deleted the e0/fix-5415-non-secure-randomuuid branch October 27, 2026 15:27

This branch was successfully deployed

2 active deployments
Preview – eve-docs — ddbe77cc Deployed Oct 27, 2026 by vercel[bot]
Preview – eve-pkg — ddbe77cc Deployed Oct 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c1 Relatively easy review; needs some context or an alternate approach to weigh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eve/client: optimistic send crashes on non-secure origins when crypto.randomUUID is unavailable

2 participants