Skip to content
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

Handle end-hook-thrown errors correctly #6567

Closed
trevor-scheer opened this issue Jun 13, 2022 · 1 comment · Fixed by #6846
Closed

Handle end-hook-thrown errors correctly #6567

trevor-scheer opened this issue Jun 13, 2022 · 1 comment · Fixed by #6846
Assignees
Milestone

Comments

@trevor-scheer
Copy link
Member

requestContext.document = parse(query, config.parseOptions);
await parsingDidEnd();
} catch (syntaxError) {
await parsingDidEnd(syntaxError as Error);

await executionDispatcher.invokeHook('executionDidEnd');
} catch (executionError) {
await executionDispatcher.invokeHook(
'executionDidEnd',
executionError as Error,
);

In (at least) these two cases, if the end hook itself throws, we then call it again in the catch block (but with no try/catch if it throws!). I'd say these try/catches incorrectly assume that the hook won't throw, but we should be prepared for it to throw and handle it gracefully.

This probably means calling the hook after the try/catch or something else which doesn't result in the end hook possibly being called twice.

@trevor-scheer trevor-scheer added this to the Release 4.0 milestone Jun 13, 2022
@trevor-scheer trevor-scheer changed the title Handle hook-thrown errors correctly Handle end-hook-thrown errors correctly Jun 13, 2022
@trevor-scheer trevor-scheer self-assigned this Aug 23, 2022
@trevor-scheer
Copy link
Member Author

#6846

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant