Skip to content

Commit 75bb6e3

Browse files
committed
fix(remix): Accept and return plain ServerBuild on Cloudflare instrumentBuild
1 parent 61940fc commit 75bb6e3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/remix/src/cloudflare/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ServerBuild } from '@remix-run/server-runtime';
12
import {
23
instrumentBuild as instrumentRemixBuild,
34
makeWrappedCreateRequestHandler,
@@ -14,11 +15,14 @@ export { makeWrappedCreateRequestHandler, sentryHandleError };
1415
* Instruments a Remix build to capture errors and performance data.
1516
* @param build The Remix build to instrument.
1617
* @returns The instrumented Remix build.
18+
*
19+
* Note: CreateRequestHandlerFunction from @shopify/remix-oxygen accepts a ServerBuild, not a function unlike the rest of the Remix ecosystem
20+
* That's why we accept and return a ServerBuild type here.
1721
*/
18-
export const instrumentBuild: typeof instrumentRemixBuild = build => {
22+
export const instrumentBuild = (build: ServerBuild): ServerBuild => {
1923
return instrumentRemixBuild(build, {
2024
instrumentTracing: true,
21-
});
25+
}) as ServerBuild;
2226
};
2327

2428
export type {

packages/remix/src/server/instrumentServer.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,7 @@ export function instrumentBuild(
432432

433433
export const makeWrappedCreateRequestHandler = (options?: { instrumentTracing?: boolean }) =>
434434
function (origCreateRequestHandler: CreateRequestHandlerFunction): CreateRequestHandlerFunction {
435-
return function (
436-
this: unknown,
437-
build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>),
438-
...args: unknown[]
439-
): RequestHandler {
435+
return function (this: unknown, build, ...args: unknown[]): RequestHandler {
440436
const newBuild = instrumentBuild(build, options);
441437
const requestHandler = origCreateRequestHandler.call(this, newBuild, ...args);
442438

0 commit comments

Comments
 (0)