Skip to content

Commit 8e21f0d

Browse files
authored
fix(remix): Store transaction on express req (#5595)
This sets the transaction on the response so it can be finished.
1 parent 8c58e0d commit 8e21f0d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/remix/src/utils/serverAdapters/express.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ function wrapExpressRequestHandler(
5151
}
5252

5353
const url = new URL(request.url);
54-
startRequestHandlerTransaction(url, request.method, routes, hub, pkg);
54+
const transaction = startRequestHandlerTransaction(url, request.method, routes, hub, pkg);
55+
// save a link to the transaction on the response, so that even if there's an error (landing us outside of
56+
// the domain), we can still finish it (albeit possibly missing some scope data)
57+
(res as AugmentedExpressResponse).__sentryTransaction = transaction;
5558
return origRequestHandler.call(this, req, res, next);
5659
};
5760
}

0 commit comments

Comments
 (0)