Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cloudflare/src/baseSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function getDefaultIntegrations(options: CloudflareOptions): Integration[
*/
export function initBaseSdk(options: CloudflareOptions): CloudflareClient | undefined {
const cached = getCachedClient();
// oxlint-disable-next-line typescript/no-deprecated
const cacheEnabled = options.cacheClient !== false;

// A closed client drops all data. `close()` marks the client before it
Expand Down Expand Up @@ -114,6 +115,7 @@ export function initBaseSdk(options: CloudflareOptions): CloudflareClient | unde

const clientOptions: CloudflareClientOptions = {
...options,
// oxlint-disable-next-line typescript/no-deprecated
cacheClient: cacheEnabled,
stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
integrations: getIntegrationsToSetup(options),
Expand Down
6 changes: 6 additions & 0 deletions packages/cloudflare/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class CloudflareClient extends ServerRuntimeClient {

super(clientOptions);
this._flushLock = flushLock;
// oxlint-disable-next-line typescript/no-deprecated
this.isCachedClient = options.cacheClient === true;

// Track span lifecycle to know when to flush. Skipped for cached clients
Expand Down Expand Up @@ -537,6 +538,7 @@ interface BaseCloudflareOptions {
*/
spotlight?: boolean | string;

// TODO(v12): Remove `cacheClient` and the per-invocation client code paths it enables.
/**
* Cache the client and reuse it across invocations within the same isolate.
*
Expand All @@ -557,6 +559,10 @@ interface BaseCloudflareOptions {
* handler completes.
*
* @default true
*
* @deprecated `cacheClient` will be removed in the next major version (v12), and the client will always be cached.
* If you set `cacheClient: false`, please open an issue at https://github.com/getsentry/sentry-javascript/issues
* and tell us why `cacheClient: true` does not work for your use case.
*/
cacheClient?: boolean;

Expand Down
1 change: 1 addition & 0 deletions packages/cloudflare/src/durableobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function constructInstrumentedDurableObject<E, T extends DurableObject<E>
// `blockConcurrencyWhile`. Their channel integrations only subscribe in `init()`, and an isolate
// that runs only this Durable Object has no earlier handler that called it. A per-invocation
// client (`cacheClient: false`) would have no invocation to flush it, so it waits for one.
// oxlint-disable-next-line typescript/no-deprecated
if (options.cacheClient !== false) {
init({ ...options });
flushDeferredChannelEvents();
Expand Down
Loading