Skip to content

Commit

Permalink
fix(browser): remove crypto.randomUUID from the client (#6079)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed Jul 10, 2024
1 parent 80a43d5 commit 04c83ac
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/browser/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const HOST = [location.hostname, PORT].filter(Boolean).join(':')
export const SESSION_ID
= PAGE_TYPE === 'orchestrator'
? getBrowserState().contextId
: crypto.randomUUID()
: getBrowserState().testerId
export const ENTRY_URL = `${
location.protocol === 'https:' ? 'wss:' : 'ws:'
}//${HOST}/__vitest_browser_api__?type=${PAGE_TYPE}&sessionId=${SESSION_ID}`
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/client/public/esm-client-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ window.__vitest_browser_runner__ = {
files: { __VITEST_FILES__ },
type: { __VITEST_TYPE__ },
contextId: { __VITEST_CONTEXT_ID__ },
testerId: { __VITEST_TESTER_ID__ },
provider: { __VITEST_PROVIDER__ },
providedContext: { __VITEST_PROVIDED_CONTEXT__ },
};
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/client/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface BrowserRunnerState {
wrapModule: <T>(module: () => T) => T
iframeId?: string
contextId: string
testerId: string
runTests?: (tests: string[]) => Promise<void>
createTesters?: (files: string[]) => Promise<void>
cdp?: {
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/node/serverOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function resolveOrchestrator(
__VITEST_FILES__: JSON.stringify(files),
__VITEST_TYPE__: '"orchestrator"',
__VITEST_CONTEXT_ID__: JSON.stringify(contextId),
__VITEST_TESTER_ID__: '"none"',
__VITEST_PROVIDED_CONTEXT__: '{}',
})

Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/node/serverTester.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { IncomingMessage, ServerResponse } from 'node:http'
import crypto from 'node:crypto'
import { stringify } from 'flatted'
import { replacer } from './utils'
import type { BrowserServer } from './server'
Expand Down Expand Up @@ -48,6 +49,7 @@ export async function resolveTester(
}),
__VITEST_TYPE__: '"tester"',
__VITEST_CONTEXT_ID__: JSON.stringify(contextId),
__VITEST_TESTER_ID__: JSON.stringify(crypto.randomUUID()),
__VITEST_PROVIDED_CONTEXT__: JSON.stringify(stringify(project.getProvidedContext())),
})

Expand Down

0 comments on commit 04c83ac

Please sign in to comment.