Skip to content

fix: await openBrowser before resolving start - #5805

Closed
AKSHAYUJJWAL286 wants to merge 2 commits into
webpack:mainfrom
AKSHAYUJJWAL286:fix/await-open-browser
Closed

AKSHAYUJJWAL286 wants to merge 2 commits into
webpack:mainfrom
AKSHAYUJJWAL286:fix/await-open-browser

Conversation

@AKSHAYUJJWAL286

@AKSHAYUJJWAL286 AKSHAYUJJWAL286 commented Nov 17, 2026 •

Copy link
Copy Markdown

Fixes #5804


Summary

In Server.prototype.openBrowser, browser launch operations across target URLs are handled using open(...). While the method is declared async and awaited by logStatus() (await this.openBrowser(openTarget)), the internal Promise.all(...) call was previously neither returned nor awaited.

Because of this, await server.start() resolved prematurely before external browser launch processes were spawned or any launch rejections were caught. This change adds await Promise.all(...) inside openBrowser(), ensuring server.start() properly awaits browser launch completion.

What kind of change does this PR introduce?


fix

Did you add tests for your changes?

Yes. Added a unit test in test/server/open-option.test.js verifying that server.start() / openBrowser() awaits asynchronous resolution of open() before resolving.


Does this PR introduce a breaking change?

No.


If relevant, what needs to be documented once your changes are merged or what have you already documented?

A patch changeset has been added in .changeset/await-open-browser.md. No public documentation updates are required.


Use of AI

AI (Antigravity) was used to assist in locating the floating Promise.all in openBrowser, formulating the test case in test/server/open-option.test.js, and running local pre-PR verification checks. All code was locally tested and validated against the full lint and test suites.

Summary by CodeRabbit

  • Bug Fixes
    • server.start() now waits for configured browser-opening actions to finish before resolving.

Await the internal Promise.all in Server.prototype.openBrowser so that server.start() does not resolve before browser launch operations complete.

Fixes webpack#5804
@linux-foundation-easycla

linux-foundation-easycla Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

CLA Not Signed

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fe83a12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-dev-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b2c7fa3-911b-4cd1-a192-9acee7cfbedf
Commits

Reviewing files that changed from the base of the PR and between c451a85 and fe83a12.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

Walkthrough

Server.openBrowser now awaits the promises that open configured browser targets. A test verifies that server.start() resolves only after the mocked browser-opening operation completes. A patch changeset documents this behavior.

Severity of issue fixed: Medium

Merge Risk: Low · previous review c451a

server.start() now waits for browser launch to finish, as the linked issue requests. The remaining note is a small test cleanup improvement and does not affect production behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title fix: await openBrowser before resolving start matches the main change. The PR adds await to the Promise.all call in openBrowser so server.start() waits for browser launch to settle, and adds…
Linked Issues check Passed Issue #5804 requires openBrowser() to await its internal Promise.all(...) so that await server.start() does not resolve before browser launch completes. The diff between the merge base and head …
Out of Scope Changes check Passed Whole-PR changes are lib/Server.js (one-line await added in openBrowser), test/server/open-option.test.js (+25 lines, a test that delays mocked open() and asserts completion after `server.st…
Full details: Title check

Explanation

The title fix: await openBrowser before resolving start matches the main change. The PR adds await to the Promise.all call in openBrowser so server.start() waits for browser launch to settle, and adds a test and changeset for this behavior.

Full details: Linked Issues check

Explanation

Issue #5804 requires openBrowser() to await its internal Promise.all(...) so that await server.start() does not resolve before browser launch completes. The diff between the merge base and head in lib/Server.js changes Promise.all( to await Promise.all( inside Server.prototype.openBrowser. This is the proposed fix in the issue. The open(...) calls already attach .catch(...) inside the map, so the awaited promise does not reject on individual launch failures. The logStatus() call site already awaits openBrowser, so the await now propagates through server.start(). The issue has no other coding requirements. The test and changeset are supporting artifacts. The test itself was not independently inspected in this review.

Full details: Out of Scope Changes check

Explanation

Whole-PR changes are lib/Server.js (one-line await added in openBrowser), test/server/open-option.test.js (+25 lines, a test that delays mocked open() and asserts completion after server.start() resolves), and .changeset/await-open-browser.md (patch changeset). The test directly verifies the fixed behavior and the changeset documents a patch fix. All changes connect to issue #5804. No unrelated changes were identified in the inspected diff.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c0378c04-49e4-4793-bba9-4f6e45f8f423
Commits

Reviewing files that changed from the base of the PR and between 796262e and c451a85.

Files selected for processing: 3

  • .changeset/await-open-browser.md
  • lib/Server.js
  • test/server/open-option.test.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment on lines +945 to +946
expect(completed).toBe(true);
await server.stop();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Stability & Availability · Quick win

Stop the server when the assertion fails.

If the missing-await regression returns, Line 945 throws before server.stop() runs. The suite's afterEach only clears and restores the mock; it does not close this server. The failed test therefore leaves the listening server and compiler watcher active. (raw.githubusercontent.com)

Put the assertion inside try and call await server.stop() in finally. This preserves cleanup on both passing and failing assertions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: openBrowser does not await Promise.all, resolving server.start() prematurely

1 participant