File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/features/device-logs/lib Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -121,11 +121,19 @@ export const storeStream =
121121 } ;
122122
123123function handleStoreErrors ( req : Request , res : Response , err : Error ) {
124- if ( handleHttpErrors ( req , res , err ) ) {
125- return ;
124+ if ( ! ( err instanceof errors . HttpError ) ) {
125+ // Log non `HttpError`s regardless of headers state
126+ captureException ( err , 'Failed to store device logs' ) ;
127+ }
128+ if ( res . headersSent ) {
129+ // If headers are already sent, we can't change the response code so we just end the response
130+ res . end ( ) ;
131+ } else {
132+ if ( handleHttpErrors ( req , res , err ) ) {
133+ return ;
134+ }
135+ res . status ( 500 ) . end ( ) ;
126136 }
127- captureException ( err , 'Failed to store device logs' ) ;
128- res . status ( 500 ) . end ( ) ;
129137}
130138
131139const primaryBackend = await getPrimaryBackend ( ) ;
You can’t perform that action at this time.
0 commit comments