-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(client): prevent overlay from closing immediately on runtime error at initial load #5653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
91cfd01
45bb778
6f04d94
6110319
653c034
fa89a05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| "use strict"; | ||
|
|
||
| const path = require("node:path"); | ||
| const puppeteer = require("puppeteer"); | ||
| const webpack = require("webpack"); | ||
| const WebpackDevServer = require("../../lib/Server"); | ||
|
|
||
| describe("overlay runtime error", () => { | ||
| let browser; | ||
| let page; | ||
| let server; | ||
|
|
||
| beforeAll(async () => { | ||
| const config = { | ||
| mode: "development", | ||
| entry: path.resolve(__dirname, "../fixtures/overlay-runtime-error.js"), | ||
| }; | ||
|
|
||
| const compiler = webpack(config); | ||
|
|
||
| server = new WebpackDevServer( | ||
| { | ||
| port: 8081, | ||
| client: { | ||
| overlay: true, | ||
| }, | ||
| }, | ||
| compiler, | ||
| ); | ||
|
|
||
| await server.start(); | ||
|
|
||
| browser = await puppeteer.launch(); | ||
| page = await browser.newPage(); | ||
| }); | ||
|
|
||
| afterAll(async () => { | ||
| await browser.close(); | ||
| await server.stop(); | ||
| }); | ||
|
|
||
| it("should keep overlay visible on runtime error during initial load", async () => { | ||
| await page.goto("http://localhost:8081"); | ||
|
|
||
| const overlay = await page.$("webpack-dev-server-client-overlay"); | ||
|
|
||
| expect(overlay).not.toBeNull(); | ||
| }); | ||
| }); | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| throw new Error("Initial runtime error"); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code can be run in web workers and it will broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out. I’ve updated it to use self instead of window so it works correctly in web workers as well. Please take another look.