Skip to content

Commit

Permalink
fix(remix): Do not skip error handling if tracing is not enabled. (#5811
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
onurtemizkan committed Sep 26, 2022
1 parent 8000012 commit 630ed9c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/remix/src/utils/instrumentServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ function makeWrappedDocumentRequestFunction(
const activeTransaction = getActiveTransaction();
const currentScope = getCurrentHub().getScope();

if (!activeTransaction || !currentScope) {
if (!currentScope) {
return origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context);
}

try {
const span = activeTransaction.startChild({
const span = activeTransaction?.startChild({
op: 'remix.server.documentRequest',
description: activeTransaction.name,
tags: {
Expand All @@ -125,7 +125,7 @@ function makeWrappedDocumentRequestFunction(

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

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

if (!activeTransaction || !currentScope) {
if (!currentScope) {
return origFn.call(this, args);
}

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

currentScope.setSpan(activeTransaction);
span.finish();
span?.finish();
} catch (err) {
captureRemixServerException(err, name);
throw err;
Expand Down

0 comments on commit 630ed9c

Please sign in to comment.