Skip to content

Commit 02878ec

Browse files
committed
fix: check for snapshot existence first
1 parent f379ed5 commit 02878ec

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/nextjs/src/server/prepareSafeIdGeneratorContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export function prepareSafeIdGeneratorContext(): void {
1313
const sym = Symbol.for('__SENTRY_SAFE_RANDOM_ID_WRAPPER__');
1414
const globalWithSymbol: typeof GLOBAL_OBJ & { [sym]?: RandomSafeContextRunner } = GLOBAL_OBJ;
1515
const als = getAsyncLocalStorage();
16-
if (!als) {
16+
if (!als || typeof als.snapshot !== 'function') {
1717
DEBUG_BUILD &&
1818
debug.warn(
19-
'[@sentry/nextjs] No AsyncLocalStorage found in the runtime, skipping safe random ID generator context preparation, you may see some errors with Cache components.',
19+
'[@sentry/nextjs] No AsyncLocalStorage found in the runtime or AsyncLocalStorage.snapshot() is not available, skipping safe random ID generator context preparation, you may see some errors with cache components.',
2020
);
2121
return;
2222
}

0 commit comments

Comments
 (0)