File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ class BundleAnalyzerPlugin {
6969 // Making analyzer logs to be after all webpack logs in the console
7070 setImmediate ( async ( ) => {
7171 try {
72- await Promise . all ( actions . map ( action => action ( ) ) ) ;
72+ await Promise . all ( actions . map ( ( action ) => action ( ) ) ) ;
7373 } finally {
7474 callback ( ) ;
7575 }
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ const webpack = require ( "webpack" ) ;
4+ const BundleAnalyzerPlugin = require ( "../src/BundleAnalyzerPlugin" ) ;
5+
6+ describe ( "Issue #499" , ( ) => {
7+ it ( "should not cause WebpackLogger 'done hook' error when callback throws" , ( done ) => {
8+ const compiler = webpack ( {
9+ mode : "development" ,
10+ entry : __filename ,
11+ plugins : [ new BundleAnalyzerPlugin ( { analyzerMode : "disabled" } ) ]
12+ } ) ;
13+
14+ let webpackLoggerError = false ;
15+ // eslint-disable-next-line no-console
16+ const originalConsoleError = console . error ;
17+
18+ // eslint-disable-next-line no-console
19+ console . error = function ( ...args ) {
20+ const message = args . join ( " " ) ;
21+ if ( message . includes ( "No such label 'done hook'" ) ) {
22+ webpackLoggerError = true ;
23+ }
24+ // eslint-disable-next-line no-console
25+ originalConsoleError . apply ( console , args ) ;
26+ } ;
27+
28+ compiler . run ( ( ) => {
29+ try {
30+ throw new Error ( "Intentional test error" ) ;
31+ } catch {
32+ // Swallow expected error
33+ }
34+ } ) ;
35+
36+ setTimeout ( ( ) => {
37+ // eslint-disable-next-line no-console
38+ console . error = originalConsoleError ;
39+
40+ // ✅ Explicit assertion – satisfies jest/expect-expect
41+ expect ( webpackLoggerError ) . toBe ( false ) ;
42+ done ( ) ;
43+ } , 1000 ) ;
44+ } ) ;
45+ } ) ;
You can’t perform that action at this time.
0 commit comments