-
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
Await on graphql.execute() before calling executionDidEnd handler (AS-59) #2298
Conversation
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.
Makes sense!
It's usually not necessary to await
a promise before returning it from an async
function, because it will just get rolled into the final promise, but in this case the timing of the finally
block is what matters.
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.
Great find and LGTM.
As we discussed on our call: Were this execute
used anywhere else besides the place where it's used, it might have been tempting to suggest wrapping the execution in a return
-'d Promise.resolve
with a .then(onFulfilled, onRejected)
where fulfillment or rejection both called executionDidEnd()
to preserve the async
dynamics, but given the limited scope, this is great.
Also as discussed, a test which ensures that the duration
amounts in the traces mathematically match up would be welcomed either in this PR or as a follow-up (since we could use more of those in general). Your call!
82f7138
to
8b9af1c
Compare
Thanks for the reviews! |
* test: ensure "total duration" > "duration of resolvers" Add test for #2298 * Update tracing duration test to be more comprehensive Previously we were only guaranteeing that individual resolvers didn't have a duration longer than the total duration. The updated test guarantees that the duration (from when the first resolver started to when the last resolver ended) should be less than total duration * Add another resolver to tracing test * Prefer `const` over `let` for variables which aren't mutated.
Glad you guys found and fixed this so quickly! I was scratching my head for hours on this before I contacted about the issue. Eagerly awaiting the new version for my own testing!! |
@dragonfriend0013 This has been released in |
extensionStack
's executionDidEnd handler (the callback function returned fromexecutionDidStart
) was being called beforegraphql.execute
finishes runningThis PR adds an
await
before the return so code infinally
runs aftergraphql.execute
finishesTODO: