File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
packages/nextjs/src/server Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1+ import { debug , GLOBAL_OBJ } from '@sentry/core' ;
2+ import { DEBUG_BUILD } from '../common/debug-build' ;
3+
4+ type SafeRandomContextRunner = < T > ( callback : ( ) => T ) => T ;
5+
6+ /**
7+ * Prepares the global object to generate safe random IDs in cache components contexts
8+ * See: https://github.com/getsentry/sentry-javascript/blob/ceb003c15973c2d8f437dfb7025eedffbc8bc8b0/packages/core/src/utils/propagationContext.ts#L1
9+ */
10+ export function prepareSafeIdGeneratorContext ( ) : void {
11+ const sym = Symbol . for ( '__SENTRY_SAFE_RANDOM_ID_WRAPPER__' ) ;
12+ const globalWithSymbol : typeof GLOBAL_OBJ & { [ sym ] ?: SafeRandomContextRunner } = GLOBAL_OBJ ;
13+ globalWithSymbol [ sym ] = AsyncLocalStorage . snapshot ( ) ;
14+
15+ DEBUG_BUILD && debug . log ( '[@sentry/nextjs] Prepared safe random ID generator context' ) ;
16+ }
You can’t perform that action at this time.
0 commit comments