Files
klz-cables.com/.pnpm-store/v10/files/0c/b11dc88080b01babc4a9b8b1f7f7090dcdb3a1adcf9829f6d22167c0dae335e6abd8f8d9437c41cf0fe40aefe8c1ab9efb304a150383798c8970c308eaa1c7
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

69 lines
2.2 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const object = require('../utils/object.js');
const worldwide = require('../utils/worldwide.js');
const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
/** Wrap a scope with a WeakRef if available, falling back to a direct scope. */
function wrapScopeWithWeakRef(scope) {
try {
// @ts-expect-error - WeakRef is not available in all environments
const WeakRefClass = worldwide.GLOBAL_OBJ.WeakRef;
if (typeof WeakRefClass === 'function') {
return new WeakRefClass(scope);
}
} catch {
// WeakRef not available or failed to create
// We'll fall back to a direct scope
}
return scope;
}
/** Try to unwrap a scope from a potential WeakRef wrapper. */
function unwrapScopeFromWeakRef(scopeRef) {
if (!scopeRef) {
return undefined;
}
if (typeof scopeRef === 'object' && 'deref' in scopeRef && typeof scopeRef.deref === 'function') {
try {
return scopeRef.deref();
} catch {
return undefined;
}
}
// Fallback to a direct scope
return scopeRef ;
}
/** Store the scope & isolation scope for a span, which can the be used when it is finished. */
function setCapturedScopesOnSpan(span, scope, isolationScope) {
if (span) {
object.addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, wrapScopeWithWeakRef(isolationScope));
// We don't wrap the scope with a WeakRef here because webkit aggressively garbage collects
// and scopes are not held in memory for long periods of time.
object.addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
}
}
/**
* Grabs the scope and isolation scope off a span that were active when the span was started.
* If WeakRef was used and scopes have been garbage collected, returns undefined for those scopes.
*/
function getCapturedScopesOnSpan(span) {
const spanWithScopes = span ;
return {
scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],
isolationScope: unwrapScopeFromWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),
};
}
exports.getCapturedScopesOnSpan = getCapturedScopesOnSpan;
exports.setCapturedScopesOnSpan = setCapturedScopesOnSpan;
//# sourceMappingURL=utils.js.map