File tree Expand file tree Collapse file tree
packages/astro/src/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,12 +184,18 @@ async function instrumentRequest(
184184
185185 const newResponseStream = new ReadableStream ( {
186186 start : async controller => {
187- for await ( const chunk of originalBody ) {
188- const html = typeof chunk === 'string' ? chunk : decoder . decode ( chunk , { stream : true } ) ;
189- const modifiedHtml = addMetaTagToHead ( html ) ;
190- controller . enqueue ( new TextEncoder ( ) . encode ( modifiedHtml ) ) ;
187+ try {
188+ for await ( const chunk of originalBody ) {
189+ const html = typeof chunk === 'string' ? chunk : decoder . decode ( chunk , { stream : true } ) ;
190+ const modifiedHtml = addMetaTagToHead ( html ) ;
191+ controller . enqueue ( new TextEncoder ( ) . encode ( modifiedHtml ) ) ;
192+ }
193+ } catch ( e ) {
194+ sendErrorToSentry ( e ) ;
195+ controller . error ( e ) ;
196+ } finally {
197+ controller . close ( ) ;
191198 }
192- controller . close ( ) ;
193199 } ,
194200 } ) ;
195201
You can’t perform that action at this time.
0 commit comments