File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -646,7 +646,9 @@ const createOverlay = (options) => {
646646 */
647647 const handleError = ( error , fallbackMessage ) => {
648648 const errorObject =
649- error instanceof Error ? error : new Error ( error || fallbackMessage ) ;
649+ error instanceof Error
650+ ? error
651+ : new Error ( error || fallbackMessage , { cause : error } ) ;
650652
651653 const shouldDisplay =
652654 typeof options . catchRuntimeError === "function"
Original file line number Diff line number Diff line change @@ -1867,6 +1867,53 @@ describe("overlay", () => {
18671867 }
18681868 } ) ;
18691869
1870+ it ( "should not show filtered promise rejection with specific error cause" , async ( ) => {
1871+ const compiler = webpack ( config ) ;
1872+
1873+ const server = new Server (
1874+ {
1875+ port,
1876+ client : {
1877+ overlay : {
1878+ runtimeErrors : ( error ) =>
1879+ ! / I n j e c t e d / . test ( error . cause . error . message ) ,
1880+ } ,
1881+ } ,
1882+ } ,
1883+ compiler ,
1884+ ) ;
1885+
1886+ await server . start ( ) ;
1887+
1888+ const { page, browser } = await runBrowser ( ) ;
1889+
1890+ try {
1891+ await page . goto ( `http://localhost:${ port } /` , {
1892+ waitUntil : "networkidle0" ,
1893+ } ) ;
1894+
1895+ await page . addScriptTag ( {
1896+ content : `(function throwError() {
1897+ setTimeout(function () {
1898+ Promise.reject({ error: new Error('Injected async error') });
1899+ }, 0);
1900+ })();` ,
1901+ } ) ;
1902+
1903+ // Delay for the overlay to appear
1904+ await delay ( 1000 ) ;
1905+
1906+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
1907+
1908+ expect ( overlayHandle ) . toBe ( null ) ;
1909+ } catch ( error ) {
1910+ throw error ;
1911+ } finally {
1912+ await browser . close ( ) ;
1913+ await server . stop ( ) ;
1914+ }
1915+ } ) ;
1916+
18701917 it ( 'should show overlay when "Content-Security-Policy" is "default-src \'self\'" was used' , async ( ) => {
18711918 const compiler = webpack ( { ...config , devtool : false } ) ;
18721919
You can’t perform that action at this time.
0 commit comments