Skip to content

Commit 54b53f8

Browse files
scruffianaduthluisherranz
committed
Interactivity: Fix crypto.randomUUID crash in non-secure contexts (#76151)
* Interactivity: Fix crypto.randomUUID crash in non-secure contexts crypto.randomUUID() is only available in secure contexts (HTTPS or localhost). Sites served over plain HTTP (e.g. http://wp-src.test) crash the entire interactivity module at import time. Add a feature-detection guard that falls back to a Math.random-based identifier when crypto.randomUUID is unavailable. The sessionId only needs to be unique per page load, not cryptographically secure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Interactivity: Use crypto.getRandomValues for sessionId fallback crypto.getRandomValues is available in all contexts (not just secure contexts like randomUUID), providing a better fallback than Math.random. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Simplify sessionId * Add changelog Also fixes previous entry --------- Co-authored-by: scruffian <scruffian@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org>
1 parent d431ff2 commit 54b53f8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

‎packages/interactivity/CHANGELOG.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
## Unreleased
44

5+
### Bug Fixes
6+
7+
- Fix `sessionId` generation crashing in non-secure (non-HTTPS) contexts. ([#76151](https://github.com/WordPress/gutenberg/pull/76151))
8+
- Add `initialVdomPromise` synchronization promise to ensure the router waits for hydration to complete before initializing, fixing dead DOM on Safari and Firefox. ([#76053](https://github.com/WordPress/gutenberg/pull/76053))
9+
510
## 6.41.0 (2026-03-04)
611

712
## 6.40.0 (2026-02-18)
813

914
### New Features
1015

11-
- Export `watch()` function for subscribing to signal changes outside of directives.
16+
- Export `watch()` function for subscribing to signal changes outside of directives. ([#75563](https://github.com/WordPress/gutenberg/pull/75563))
1217

1318
## 6.39.0 (2026-01-29)
1419

‎packages/interactivity/src/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export const navigationSignal = signal( 0 );
518518
* events for entries created in a previous session trigger a full reload
519519
* instead of a client-side navigation that would leave stale content.
520520
*/
521-
export const sessionId = crypto.randomUUID();
521+
export const sessionId = Math.random().toString( 36 ).slice( 2 );
522522

523523
/**
524524
* Recursively clones the passed object.

0 commit comments

Comments
 (0)