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 @@ -637,7 +637,9 @@ const createOverlay = (options) => {
637
637
*/
638
638
const handleError = ( error , fallbackMessage ) => {
639
639
const errorObject =
640
- error instanceof Error ? error : new Error ( error || fallbackMessage ) ;
640
+ error instanceof Error
641
+ ? error
642
+ : new Error ( error || fallbackMessage , { cause : error } ) ;
641
643
642
644
const shouldDisplay =
643
645
typeof options . catchRuntimeError === "function"
Original file line number Diff line number Diff line change @@ -1930,6 +1930,53 @@ describe("overlay", () => {
1930
1930
}
1931
1931
} ) ;
1932
1932
1933
+ it ( "should not show 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 ) =>
1942
+ ! / I n j e c t e d / . test ( error . cause . error . message ) ,
1943
+ } ,
1944
+ } ,
1945
+ } ,
1946
+ compiler ,
1947
+ ) ;
1948
+
1949
+ await server . start ( ) ;
1950
+
1951
+ const { page, browser } = await runBrowser ( ) ;
1952
+
1953
+ try {
1954
+ await page . goto ( `http://localhost:${ port } /` , {
1955
+ waitUntil : "networkidle0" ,
1956
+ } ) ;
1957
+
1958
+ await page . addScriptTag ( {
1959
+ content : `(function throwError() {
1960
+ setTimeout(function () {
1961
+ Promise.reject({ error: new Error('Injected async error') });
1962
+ }, 0);
1963
+ })();` ,
1964
+ } ) ;
1965
+
1966
+ // Delay for the overlay to appear
1967
+ await delay ( 1000 ) ;
1968
+
1969
+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
1970
+
1971
+ expect ( overlayHandle ) . toBe ( null ) ;
1972
+ } catch ( error ) {
1973
+ throw error ;
1974
+ } finally {
1975
+ await browser . close ( ) ;
1976
+ await server . stop ( ) ;
1977
+ }
1978
+ } ) ;
1979
+
1933
1980
it ( 'should show overlay when "Content-Security-Policy" is "default-src \'self\'" was used' , async ( ) => {
1934
1981
const compiler = webpack ( { ...config , devtool : false } ) ;
1935
1982
You can’t perform that action at this time.
0 commit comments