Skip to content

Commit d760cb7

Browse files
committed
Clean up worker transport.
1 parent ec68787 commit d760cb7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/remix/src/index.client.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { ServerRuntimeClientOptions } from '@sentry/core';
1010
import { configureScope, getCurrentHub, getIntegrationsToSetup, initAndBind, ServerRuntimeClient } from '@sentry/core';
1111
import { createStackParser, logger, nodeStackLineParser, stackParserFromStackParserOptions } from '@sentry/utils';
1212

13-
import { makeCloudflareTransport } from './worker/transport';
13+
import { makeWorkerTransport } from './worker/transport';
1414

1515
export { captureRemixServerException } from './utils/instrumentServer';
1616
export { ErrorBoundary, withErrorBoundary } from '@sentry/react';
@@ -46,7 +46,7 @@ export function workerInit(options: RemixOptions): void {
4646
...options,
4747
stackParser: stackParserFromStackParserOptions(options.stackParser || nodeStackParser),
4848
integrations: getIntegrationsToSetup(options),
49-
transport: options.transport || makeCloudflareTransport,
49+
transport: options.transport || makeWorkerTransport,
5050
};
5151

5252
initAndBind(ServerRuntimeClient, clientOptions);

packages/remix/src/worker/transport.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { createTransport } from '@sentry/core';
22
import type { BaseTransportOptions, Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';
33

4-
export type CloudflareWorkersTransportOptions = BaseTransportOptions & {
4+
export type WorkersTransportOptions = BaseTransportOptions & {
55
headers?: Record<string, string>;
66
context?: Record<string, any>;
77
fetcher?: typeof fetch;
88
};
99

1010
/**
11-
* Creates a Transport that uses the Cloudflare Workers' fetch API to send events to Sentry.
11+
* Creates a Transport that uses the Cloudflare Workers' or Shopify Oxygen's fetch API to send events to Sentry.
1212
*/
13-
export function makeCloudflareTransport(options: CloudflareWorkersTransportOptions): Transport {
13+
export function makeWorkerTransport(options: WorkersTransportOptions): Transport {
1414
function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {
1515
const requestOptions: RequestInit = {
1616
body: request.body,
@@ -28,6 +28,8 @@ export function makeCloudflareTransport(options: CloudflareWorkersTransportOptio
2828
};
2929
});
3030

31+
// If we're in a Cloudflare Worker, wait for the fetch to complete
32+
// before returning. This ensures that the Worker doesn't shut down
3133
if (options.context && options.context.waitUntil) {
3234
options.context.waitUntil(fetchRequest);
3335
}

0 commit comments

Comments
 (0)