File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -637,7 +637,9 @@ const createOverlay = (options) => {
637637 */
638638 const handleError = ( error , fallbackMessage ) => {
639639 const errorObject =
640- error instanceof Error ? error : new Error ( error || fallbackMessage ) ;
640+ error instanceof Error
641+ ? error
642+ : new Error ( error || fallbackMessage , { cause : error } ) ;
641643
642644 const shouldDisplay =
643645 typeof options . catchRuntimeError === "function"
Original file line number Diff line number Diff line change @@ -1930,6 +1930,52 @@ describe("overlay", () => {
19301930 }
19311931 } ) ;
19321932
1933+ it ( "should not display overlay for filtered promise rejection with specific error cause" , async ( ) => {
1934+ const compiler = webpack ( config ) ;
1935+
1936+ const server = new Server (
1937+ {
1938+ port,
1939+ client : {
1940+ overlay : {
1941+ runtimeErrors : ( error ) => ! / I n j e c t e d / . test ( error . cause . message ) ,
1942+ } ,
1943+ } ,
1944+ } ,
1945+ compiler ,
1946+ ) ;
1947+
1948+ await server . start ( ) ;
1949+
1950+ const { page, browser } = await runBrowser ( ) ;
1951+
1952+ try {
1953+ await page . goto ( `http://localhost:${ port } /` , {
1954+ waitUntil : "networkidle0" ,
1955+ } ) ;
1956+
1957+ await page . addScriptTag ( {
1958+ content : `(function throwError() {
1959+ setTimeout(function () {
1960+ Promise.reject(new Error('Injected async error'));
1961+ }, 0);
1962+ })();` ,
1963+ } ) ;
1964+
1965+ // Delay for the overlay to appear
1966+ await delay ( 1000 ) ;
1967+
1968+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
1969+
1970+ expect ( overlayHandle ) . toBe ( null ) ;
1971+ } catch ( error ) {
1972+ throw error ;
1973+ } finally {
1974+ await browser . close ( ) ;
1975+ await server . stop ( ) ;
1976+ }
1977+ } ) ;
1978+
19331979 it ( 'should show overlay when "Content-Security-Policy" is "default-src \'self\'" was used' , async ( ) => {
19341980 const compiler = webpack ( { ...config , devtool : false } ) ;
19351981
You can’t perform that action at this time.
0 commit comments