@@ -188,14 +188,9 @@ function getFilenameFromUrl(context, url) {
188188 foundFilename = filename ;
189189
190190 // Rspack does not yet support `assetsInfo`, so we need to check if `assetsInfo` exists here
191- if ( assetsInfo ) {
192- const assetInfo = assetsInfo . get (
193- pathname . slice ( publicPathPathname . length ) ,
194- ) ;
195-
196- extra . immutable = assetInfo ? assetInfo . immutable : false ;
197- }
198-
191+ extra . immutable = assetsInfo
192+ ? assetsInfo . get ( pathname . slice ( publicPathPathname . length ) ) ?. immutable
193+ : false ;
199194 extra . outputFileSystem = outputFileSystem ;
200195
201196 break ;
@@ -1077,20 +1072,15 @@ function wrapper(context) {
10771072 return ;
10781073 }
10791074
1080- // Cleanup
1081- const cleanup = ( ) => {
1082- destroyStream (
1083- /** @type {import("fs").ReadStream } */ ( bufferOrStream ) ,
1084- true ,
1085- ) ;
1086- } ;
1087-
10881075 // Error handling
10891076 /** @type {import("fs").ReadStream } */
10901077 ( bufferOrStream ) . on ( "error" , ( error ) => {
10911078 context . logger . error ( "Stream error:" , error ) ;
10921079 // clean up stream early
1093- cleanup ( ) ;
1080+ destroyStream (
1081+ /** @type {import("fs").ReadStream } */ ( bufferOrStream ) ,
1082+ true ,
1083+ ) ;
10941084 errorHandler ( error ) ;
10951085 } ) ;
10961086
@@ -1100,7 +1090,16 @@ function wrapper(context) {
11001090
11011091 if ( outgoing ) {
11021092 // Response finished, cleanup
1103- onFinishedStream ( outgoing , cleanup ) ;
1093+ onFinishedStream ( outgoing , ( err ) => {
1094+ if ( err ) {
1095+ context . logger . error ( "Stream error:" , err ) ;
1096+ }
1097+
1098+ destroyStream (
1099+ /** @type {import("fs").ReadStream } */ ( bufferOrStream ) ,
1100+ true ,
1101+ ) ;
1102+ } ) ;
11041103 }
11051104 }
11061105
0 commit comments