Skip to content

Commit 630ed9c

Browse files
authored
fix(remix): Do not skip error handling if tracing is not enabled. (#5811)
We were early returning wrappers (which are also responsible for most errors to handle) if there isn't an active transaction. This PR removes it and early returns only if there isn't a scope defined.
1 parent 8000012 commit 630ed9c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/remix/src/utils/instrumentServer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ function makeWrappedDocumentRequestFunction(
109109
const activeTransaction = getActiveTransaction();
110110
const currentScope = getCurrentHub().getScope();
111111

112-
if (!activeTransaction || !currentScope) {
112+
if (!currentScope) {
113113
return origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context);
114114
}
115115

116116
try {
117-
const span = activeTransaction.startChild({
117+
const span = activeTransaction?.startChild({
118118
op: 'remix.server.documentRequest',
119119
description: activeTransaction.name,
120120
tags: {
@@ -125,7 +125,7 @@ function makeWrappedDocumentRequestFunction(
125125

126126
res = await origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context);
127127

128-
span.finish();
128+
span?.finish();
129129
} catch (err) {
130130
captureRemixServerException(err, 'documentRequest');
131131
throw err;
@@ -141,12 +141,12 @@ function makeWrappedDataFunction(origFn: DataFunction, id: string, name: 'action
141141
const activeTransaction = getActiveTransaction();
142142
const currentScope = getCurrentHub().getScope();
143143

144-
if (!activeTransaction || !currentScope) {
144+
if (!currentScope) {
145145
return origFn.call(this, args);
146146
}
147147

148148
try {
149-
const span = activeTransaction.startChild({
149+
const span = activeTransaction?.startChild({
150150
op: `remix.server.${name}`,
151151
description: id,
152152
tags: {
@@ -162,7 +162,7 @@ function makeWrappedDataFunction(origFn: DataFunction, id: string, name: 'action
162162
res = await origFn.call(this, args);
163163

164164
currentScope.setSpan(activeTransaction);
165-
span.finish();
165+
span?.finish();
166166
} catch (err) {
167167
captureRemixServerException(err, name);
168168
throw err;

0 commit comments

Comments
 (0)