apollo-server icon indicating copy to clipboard operation
apollo-server copied to clipboard

willResolveField end hook not guaranteed to be called before end of execution

Open glasser opened this issue 4 years ago • 2 comments

willResolveField end hooks (which at least are sync) are called from this special whenResultIsFinished on the result of a resolver. But that's in parallel with the processing done on that promise by GraphQL execution. So it's possible that it will be called later than the end of execution.

What this rolls up into is that endTime might end up missing from some nodes at the time the trace is either pre-encoded or converted to stats, so they will be missing an endTime on the trace and will not be counted for TypeStats if converted in the usage reporting plugin.

glasser avatar Jun 25 '21 23:06 glasser

This was caught by our internal inconsistent_reports_records_in_gcs monitor in staging, which we should re-enable once this is fixed.

glasser avatar Jul 23 '21 16:07 glasser

Ideally we would fix this by adding a less hacky way to instrument execution to graphql-js.

#4667 is sorta similar/related.

glasser avatar Oct 21 '22 06:10 glasser