Skip to content

Commit

Permalink
Apply a .catch to the un-await'd call to addTrace.
Browse files Browse the repository at this point in the history
Also, add a comment indicating the intent.  The `logger` in this case will
be a request-specific logger when available or the general "Engine" logger
otherwise.

Related: #2670
  • Loading branch information
abernix committed May 20, 2020
1 parent 5cf2986 commit 9d17c27
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/apollo-engine-reporting/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ export const plugin = <TContext>(
treeBuilder.trace.queryPlan = metrics.queryPlanTrace;
}

// Intentionally un-awaited so as not to block the response. Any
// errors will be logged, but will not manifest a user-facing error.
// The logger in this case is a request specific logger OR the logger
// defined by the plugin if that's unavailable. The request-specific
// logger is preferred since this is very much coupled directly to a
// client-triggered action which might be more granularly tagged by
// logging implementations.
addTrace({
operationName,
queryHash: requestContext.queryHash!,
Expand All @@ -162,7 +169,7 @@ export const plugin = <TContext>(
options.experimental_overrideReportedSchema || schema,
),
logger,
});
}).catch(logger.error);
}

// While we start the tracing as soon as possible, we only actually report
Expand Down

0 comments on commit 9d17c27

Please sign in to comment.