-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apollo-engine-reporting: fix reporting errors from backends #3056
Conversation
6a09868
to
3b6af6a
Compare
5e6f2f4
to
c9945b7
Compare
I sent more details to Adam on slack as I'm in transit but:
|
Can you get a test for this PR? Look at the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and add a test please
@@ -34,6 +34,14 @@ export class EngineFederatedTracingExtension<TContext = any> | |||
if (this.enabled) { | |||
this.treeBuilder.startTiming(); | |||
} | |||
|
|||
return () => { | |||
// It's possible that execution never started! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does something here need to check this.enabled?
@@ -100,13 +109,6 @@ export class EngineReportingTreeBuilder { | |||
path: ReadonlyArray<string | number> | undefined, | |||
error: Trace.Error, | |||
) { | |||
if (!this.startHrTime) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we still removing this?
@@ -15,6 +15,7 @@ export class EngineReportingTreeBuilder { | |||
[rootResponsePath, this.rootNode], | |||
]); | |||
private rewriteError?: (err: GraphQLError) => GraphQLError | null; | |||
private consolePrefix = '[apollo-engine-reporting]'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this helpful in errors? isn't the stack trace good enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan of this as it's a clearer indication that something is seriously fucked and it's not part of the implementing application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, but in that case maybe the message should literally say it's an internal bug in the library?
and pr desc needs an update |
080d65e
to
ee4ec98
Compare
ee4ec98
to
2a31072
Compare
I rewrote this. |
2a31072
to
3d3898b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good @glasser ! I think we should capture the weirdness of validation/parsing errors not being caught and maybe noodle on how we can capture them here or in Slack.
// | ||
// Note: format() is only called after executing an operation, and | ||
// specifically isn't called for parse or validation errors. Parse and validation | ||
// errors in a federated backend will get reported to the end user as a downstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... can we track this as an issue for followup at least? Seems like it would be useful to know if the query planner is sending sub-operations that fail validation :)
@@ -6,6 +6,10 @@ import { | |||
} from 'graphql'; | |||
import { Trace, google } from 'apollo-engine-reporting-protobuf'; | |||
|
|||
function internalError(message: string) { | |||
return new Error(`[internal apollo-server error] ${message}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I do think apollo-engine-reporting
is probably more appropriate, or internal apollo metrics reporting
if we want to avoid the term engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that's in the stack trace?
The extension stack executionDidEnd method gets called before didEncounterErrors for GraphQL errors returned from execution (although confusingly the plugin executionDidEnd method gets called after), which caused the assertion that nothing gets added to the EngineReportingTreeBuilder after stopTiming to fail. Fix by moving stopTiming to the last possible moment: format(). Actually test error reporting, including both kinds of rewriting. Add a comment noting that backend parse and validation errors don't get reported. Fixes #3052.
3d3898b
to
1fd58cc
Compare
The extension stack executionDidEnd method gets called before didEncounterErrors
for GraphQL errors returned from execution (although confusingly the plugin
executionDidEnd method gets called after), which caused the assertion that
nothing gets added to the EngineReportingTreeBuilder after stopTiming to
fail. Fix by moving stopTiming to the last possible moment: format().
Actually test error reporting, including both kinds of rewriting.
Add a comment noting that backend parse and validation errors don't get
reported.
Fixes #3052.