Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,9 @@ class Server {
}

startCallback(callback) {
this.start().then(() => callback(null), callback);
this.start()
.then(() => callback(null), callback)
.catch(callback);
}

async stop() {
Expand Down Expand Up @@ -2235,7 +2237,9 @@ class Server {
}

stopCallback(callback) {
this.stop().then(() => callback(null), callback);
this.stop()
.then(() => callback(null), callback)
.catch(callback);
}

// TODO remove in the next major release
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,29 @@ describe("API", () => {
});
});

it(`should catch errors within startCallback`, async () => {
const compiler = webpack(config);
const server = new Server(
{ port, static: "https://absolute-url.com/somewhere" },
compiler
);

await new Promise((resolve) => {
server.startCallback((err) => {
expect(err.message).toEqual(
"Using a URL as static.directory is not supported"
);
resolve();
});
});

await new Promise((resolve) => {
server.stopCallback(() => {
resolve();
});
});
});

it(`should work when using configured manually`, async () => {
const compiler = webpack({
...config,
Expand Down