Skip to content

Commit 1286e9d

Browse files
committed
Await HttpAdapter.reply / FastifyReply.send
1 parent a1ece6a commit 1286e9d

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/core/exception/exception.filter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ExceptionFilter implements GqlExceptionFilter {
1818
private readonly normalizer: ExceptionNormalizer,
1919
) {}
2020

21-
catch(exception: Error, args: ArgumentsHost) {
21+
async catch(exception: Error, args: ArgumentsHost) {
2222
if (exception && (exception as any).type === 'request.aborted') {
2323
this.logger.warning('Request aborted');
2424
return;
@@ -43,7 +43,7 @@ export class ExceptionFilter implements GqlExceptionFilter {
4343
if (args.getType() === 'graphql') {
4444
this.respondToGraphQL(normalized, args);
4545
}
46-
this.respondToHttp(normalized, args);
46+
await this.respondToHttp(normalized, args);
4747
}
4848

4949
private respondToGraphQL(ex: ExceptionJson, _args: ArgumentsHost) {
@@ -53,7 +53,7 @@ export class ExceptionFilter implements GqlExceptionFilter {
5353
throw Object.assign(new Error(), out);
5454
}
5555

56-
private respondToHttp(ex: ExceptionJson, args: ArgumentsHost) {
56+
private async respondToHttp(ex: ExceptionJson, args: ArgumentsHost) {
5757
const { codes } = ex;
5858
const status = codes.has('NotFound')
5959
? HttpStatus.NOT_FOUND
@@ -78,7 +78,7 @@ export class ExceptionFilter implements GqlExceptionFilter {
7878
};
7979

8080
const res = args.switchToHttp().getResponse();
81-
this.http.reply(res, out, status);
81+
await this.http.reply(res, out, status);
8282
}
8383

8484
logIt(info: ExceptionJson, error: Error) {

src/core/http/http.adapter.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,6 @@ export class HttpAdapter extends PatchedFastifyAdapter {
128128
void response.cookie(name, value, options);
129129
}
130130

131-
// @ts-expect-error we don't need to be compatible with base
132-
reply(
133-
response: IResponse | IResponse['raw'],
134-
body: any,
135-
statusCode?: number,
136-
) {
137-
// Avoid linter wanting us to await sending response.
138-
// This method just returns the response instance for fluent interface.
139-
void super.reply(response, body, statusCode);
140-
}
141-
142131
// @ts-expect-error we don't need to be compatible with base
143132
setHeader(response: IResponse, name: string, value: string) {
144133
// Avoid linter wanting us to await sending response.

0 commit comments

Comments
 (0)