Skip to content

Handle end-hook-thrown errors correctly #6567

Closed
@trevor-scheer

Description

@trevor-scheer
Contributor

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.

Activity

added this to the Release 4.0 milestone on Jun 13, 2022
changed the title [-]Handle hook-thrown errors correctly[/-] [+]Handle end-hook-thrown errors correctly[/+] on Jun 13, 2022
trevor-scheer

trevor-scheer commented on Aug 24, 2022

@trevor-scheer
ContributorAuthor
locked as resolved and limited conversation to collaborators on Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @trevor-scheer

    Issue actions

      Handle end-hook-thrown errors correctly · Issue #6567 · apollographql/apollo-server