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>(
7676 context : { res } ,
7777 } ) ;
7878 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+ } ) ;
8890 }
8991 } catch ( err ) {
9092 // The handler shouldnt throw errors.
@@ -95,7 +97,9 @@ export function createHandler<Context extends OperationContext = undefined>(
9597 err ,
9698 ) ;
9799 if ( ! aborted ) {
98- res . writeStatus ( '500 Internal Server Error' ) . endWithoutBody ( ) ;
100+ res . cork ( ( ) => {
101+ res . writeStatus ( '500 Internal Server Error' ) . endWithoutBody ( ) ;
102+ } ) ;
99103 }
100104 }
101105 } ;
You can’t perform that action at this time.
0 commit comments