Skip to content

Commit

Permalink
fix(fastify): return error object from async handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 11, 2022
1 parent fd07f45 commit 5f72a7e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/apollo-server-fastify/src/ApolloServer.ts
Expand Up @@ -56,12 +56,12 @@ export class ApolloServer<
if (onHealthCheck) {
try {
await onHealthCheck(request);
reply.send('{"status":"pass"}');
return reply.send('{"status":"pass"}');
} catch (e) {
reply.status(503).send('{"status":"fail"}');
return reply.status(503).send('{"status":"fail"}');
}
} else {
reply.send('{"status":"pass"}');
return reply.send('{"status":"pass"}');
}
});
}
Expand Down Expand Up @@ -94,9 +94,11 @@ export class ApolloServer<

if (prefersHtml) {
reply.type('text/html');
reply.send(landingPage.html);
return reply.send(landingPage.html);
}
}

return undefined;
}
: undefined;

Expand Down Expand Up @@ -129,7 +131,7 @@ export class ApolloServer<
}
reply.status(responseInit.status || 200);
reply.serializer((payload: string) => payload);
reply.send(graphqlResponse);
return reply.send(graphqlResponse);
} catch (error) {
if (!isHttpQueryError(error)) {
throw error;
Expand All @@ -143,7 +145,7 @@ export class ApolloServer<

reply.code(error.statusCode);
reply.serializer((payload: string) => payload);
reply.send(error.message);
return reply.send(error.message);
}
},
});
Expand Down

0 comments on commit 5f72a7e

Please sign in to comment.