Skip to content

fix: backport tapPromise fix to v30.0.0 (last Vue 2 version) — webpack-dev-server hangs on watchRun #915

@yoyo837

Description

@yoyo837

Description

Version 30.0.0 is the last version that supports Vue 2, but it has a bug where tapAsync with an async callback never calls the completion callback, causing webpack-dev-server to hang at "wait until bundle finished".

This issue was already fixed in PR #907 for the main branch by changing tapAsync to tapPromise, but since there is no branch backup for v30.0.0, the fix cannot be backported via a PR.

The Fix

In src/core/unplugin.ts, the following change is needed:

- compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async () => {
+ compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {

Full context from the main branch fix:

// src/core/unplugin.ts
 webpack(compiler) {
   let watcher: Watching
   let fileDepQueue: { path: string, type: 'unlink' | 'add' }[] = []
-  compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async () => {
+  compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {
     // ensure watcher is ready(supported since webpack@5.0.0-rc.1)
     if (!watcher && compiler.watching) {
       watcher = compiler.watching

Steps to Reproduce

  1. Use unplugin-vue-components@30.0.0 with webpack-dev-server
  2. Start dev server
  3. Make a file change to trigger a rebuild
  4. webpack-dev-server hangs with "wait until bundle finished"

Expected Behavior

The dev server should rebuild and reload normally.

Why an Issue instead of a PR

Version 30.0.0 does not have a corresponding branch in the repository, so a direct PR cannot be created against it. I'm hoping the maintainers can either:

  1. Create a v30 branch and I can submit a PR against it, or
  2. Apply this one-line fix and publish a 30.0.1 patch release

Linked Issues/PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions