Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
4.6 KiB
Plaintext
1 line
4.6 KiB
Plaintext
{"version":3,"file":"asyncLocalStorageStrategy.js","sources":["../../../src/light/asyncLocalStorageStrategy.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport type { Scope } from '@sentry/core';\nimport { getDefaultCurrentScope, getDefaultIsolationScope, setAsyncContextStrategy } from '@sentry/core';\n\n/**\n * Sets the async context strategy to use AsyncLocalStorage.\n *\n * This is a lightweight alternative to the OpenTelemetry-based strategy.\n * It uses Node's native AsyncLocalStorage directly without any OpenTelemetry dependencies.\n */\nexport function setAsyncLocalStorageAsyncContextStrategy(): void {\n const asyncStorage = new AsyncLocalStorage<{\n scope: Scope;\n isolationScope: Scope;\n }>();\n\n function getScopes(): { scope: Scope; isolationScope: Scope } {\n const scopes = asyncStorage.getStore();\n\n if (scopes) {\n return scopes;\n }\n\n // fallback behavior:\n // if, for whatever reason, we can't find scopes on the context here, we have to fix this somehow\n return {\n scope: getDefaultCurrentScope(),\n isolationScope: getDefaultIsolationScope(),\n };\n }\n\n function withScope<T>(callback: (scope: Scope) => T): T {\n const scope = getScopes().scope.clone();\n const isolationScope = getScopes().isolationScope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withSetScope<T>(scope: Scope, callback: (scope: Scope) => T): T {\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope.clone();\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n function withSetIsolationScope<T>(isolationScope: Scope, callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n // In contrast to the browser, we can rely on async context isolation here\n function suppressTracing<T>(callback: () => T): T {\n return withScope(scope => {\n scope.setSDKProcessingMetadata({ __SENTRY_SUPPRESS_TRACING__: true });\n return callback();\n });\n }\n\n setAsyncContextStrategy({\n suppressTracing,\n withScope,\n withSetScope,\n withIsolationScope,\n withSetIsolationScope,\n getCurrentScope: () => getScopes().scope,\n getIsolationScope: () => getScopes().isolationScope,\n });\n}\n"],"names":[],"mappings":";;;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAS;AACjE,EAAE,MAAM,YAAA,GAAe,IAAI;;AAGzB,EAAI;;AAEN,EAAE,SAAS,SAAS,GAA4C;AAChE,IAAI,MAAM,MAAA,GAAS,YAAY,CAAC,QAAQ,EAAE;;AAE1C,IAAI,IAAI,MAAM,EAAE;AAChB,MAAM,OAAO,MAAM;AACnB,IAAI;;AAEJ;AACA;AACA,IAAI,OAAO;AACX,MAAM,KAAK,EAAE,sBAAsB,EAAE;AACrC,MAAM,cAAc,EAAE,wBAAwB,EAAE;AAChD,KAAK;AACL,EAAE;;AAEF,EAAE,SAAS,SAAS,CAAI,QAAQ,EAA0B;AAC1D,IAAI,MAAM,KAAA,GAAQ,SAAS,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,cAAA,GAAiB,SAAS,EAAE,CAAC,cAAc;AACrD,IAAI,OAAO,YAAY,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,cAAA,EAAgB,EAAE,MAAM;AAC7D,MAAM,OAAO,QAAQ,CAAC,KAAK,CAAC;AAC5B,IAAI,CAAC,CAAC;AACN,EAAE;;AAEF,EAAE,SAAS,YAAY,CAAI,K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