Skip to content

Commit b2182e1

Browse files
committed
Capture ServerBuild from factory function arg in createRequestHandler patch
1 parent 0513904 commit b2182e1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

packages/react-router/src/server/instrumentation/reactRouter.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ export class ReactRouterInstrumentation extends InstrumentationBase<Instrumentat
6767
const build = args[0];
6868
if (isServerBuildLike(build)) {
6969
setServerBuild(build);
70+
} else if (typeof build === 'function') {
71+
// Build arg can be a factory function (dev mode HMR). Wrap to capture resolved build.
72+
const originalBuildFn = build as () => unknown;
73+
args[0] = async function sentryWrappedBuildFn() {
74+
const resolvedBuild = await originalBuildFn();
75+
if (isServerBuildLike(resolvedBuild)) {
76+
setServerBuild(resolvedBuild);
77+
}
78+
return resolvedBuild;
79+
};
7080
}
7181

7282
const originalRequestHandler = original.apply(this, args);

0 commit comments

Comments
 (0)