File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -76,15 +76,17 @@ export function createHandler<Context extends OperationContext = undefined>(
76
76
context : { res } ,
77
77
} ) ;
78
78
if ( ! aborted ) {
79
- res . writeStatus ( `${ init . status } ${ init . statusText } ` ) ;
80
- for ( const [ key , val ] of Object . entries ( init . headers || { } ) ) {
81
- res . writeHeader ( key , val ) ;
82
- }
83
- if ( body ) {
84
- res . end ( body ) ;
85
- } else {
86
- res . endWithoutBody ( ) ;
87
- }
79
+ res . cork ( ( ) => {
80
+ res . writeStatus ( `${ init . status } ${ init . statusText } ` ) ;
81
+ for ( const [ key , val ] of Object . entries ( init . headers || { } ) ) {
82
+ res . writeHeader ( key , val ) ;
83
+ }
84
+ if ( body ) {
85
+ res . end ( body ) ;
86
+ } else {
87
+ res . endWithoutBody ( ) ;
88
+ }
89
+ } ) ;
88
90
}
89
91
} catch ( err ) {
90
92
// The handler shouldnt throw errors.
@@ -95,7 +97,9 @@ export function createHandler<Context extends OperationContext = undefined>(
95
97
err ,
96
98
) ;
97
99
if ( ! aborted ) {
98
- res . writeStatus ( '500 Internal Server Error' ) . endWithoutBody ( ) ;
100
+ res . cork ( ( ) => {
101
+ res . writeStatus ( '500 Internal Server Error' ) . endWithoutBody ( ) ;
102
+ } ) ;
99
103
}
100
104
}
101
105
} ;
You can’t perform that action at this time.
0 commit comments