Skip to content

Commit 04c83ac

Browse files
authored
fix(browser): remove crypto.randomUUID from the client (#6079)
1 parent 80a43d5 commit 04c83ac

File tree

5 files changed

+6
-1
lines changed

5 files changed

+6
-1
lines changed

packages/browser/src/client/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const HOST = [location.hostname, PORT].filter(Boolean).join(':')
1111
export const SESSION_ID
1212
= PAGE_TYPE === 'orchestrator'
1313
? getBrowserState().contextId
14-
: crypto.randomUUID()
14+
: getBrowserState().testerId
1515
export const ENTRY_URL = `${
1616
location.protocol === 'https:' ? 'wss:' : 'ws:'
1717
}//${HOST}/__vitest_browser_api__?type=${PAGE_TYPE}&sessionId=${SESSION_ID}`

packages/browser/src/client/public/esm-client-injector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ window.__vitest_browser_runner__ = {
2323
files: { __VITEST_FILES__ },
2424
type: { __VITEST_TYPE__ },
2525
contextId: { __VITEST_CONTEXT_ID__ },
26+
testerId: { __VITEST_TESTER_ID__ },
2627
provider: { __VITEST_PROVIDER__ },
2728
providedContext: { __VITEST_PROVIDED_CONTEXT__ },
2829
};

packages/browser/src/client/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface BrowserRunnerState {
2828
wrapModule: <T>(module: () => T) => T
2929
iframeId?: string
3030
contextId: string
31+
testerId: string
3132
runTests?: (tests: string[]) => Promise<void>
3233
createTesters?: (files: string[]) => Promise<void>
3334
cdp?: {

packages/browser/src/node/serverOrchestrator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export async function resolveOrchestrator(
3131
__VITEST_FILES__: JSON.stringify(files),
3232
__VITEST_TYPE__: '"orchestrator"',
3333
__VITEST_CONTEXT_ID__: JSON.stringify(contextId),
34+
__VITEST_TESTER_ID__: '"none"',
3435
__VITEST_PROVIDED_CONTEXT__: '{}',
3536
})
3637

packages/browser/src/node/serverTester.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { IncomingMessage, ServerResponse } from 'node:http'
2+
import crypto from 'node:crypto'
23
import { stringify } from 'flatted'
34
import { replacer } from './utils'
45
import type { BrowserServer } from './server'
@@ -48,6 +49,7 @@ export async function resolveTester(
4849
}),
4950
__VITEST_TYPE__: '"tester"',
5051
__VITEST_CONTEXT_ID__: JSON.stringify(contextId),
52+
__VITEST_TESTER_ID__: JSON.stringify(crypto.randomUUID()),
5153
__VITEST_PROVIDED_CONTEXT__: JSON.stringify(stringify(project.getProvidedContext())),
5254
})
5355

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy