GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — #20221 module existence check breaks `interceptModuleExecution` recovery for missing modules · Issue #20475 · webpack/webpack

#20221 module existence check breaks interceptModuleExecution recovery for missing modules #20475

New issue
Copy link
New issue
Copy link
Closed
Bug
#20510
Closed
#20221 module existence check breaks interceptModuleExecution recovery for missing modules#20475
Bug
#20510
Copy link

Description

@lukesandberg
lukesandberg
opened on Feb 19, 2026
Issue body actions

Bug Description

The module existence check added in #20221 (shipped in v5.104.0) changes the observable control flow of __webpack_require__ in a way that breaks plugins relying on interceptModuleExecution to handle missing modules gracefully.

What is the current behavior?

When output.pathinfo is enabled (default in development), the new check in __webpack_require__ throws before interceptModuleExecution runs:

function __webpack_require__(moduleId) {
  // 1. Cache check
  var cachedModule = __webpack_module_cache__[moduleId];
  if (cachedModule !== undefined) return cachedModule.exports;

  // 2. NEW: pathinfo existence check — throws here
  if (__webpack_modules__[moduleId] === undefined) {
    var e = new Error("Cannot find module '" + moduleId + "'");
    e.code = 'MODULE_NOT_FOUND';
    throw e;
  }

  // 3. Create module
  var module = __webpack_module_cache__[moduleId] = { ... };

  // 4. interceptModuleExecution — never reached
  var execOptions = { id: moduleId, module: module, factory: __webpack_modules__[moduleId], require: __webpack_require__ };
  __webpack_require__.i.forEach(function(handler) { handler(execOptions); });
  ...
}

Previously (≤v5.103), when __webpack_modules__[moduleId] was undefined, execution reached step 4. The factory was passed as undefined in execOptions.factory, and plugins hooking interceptModuleExecution could detect this and recover (e.g., trigger a page reload instead of crashing).

What is the expected behavior?

The interceptModuleExecution hook should still have a chance to handle missing modules. Either:

  1. Move the existence check after interceptModuleExecution runs (so plugins can intervene), or
  2. Move it after execOptions.factory is read but before .call(), so the check still fires but only when no interceptor handled it, or
  3. Gate the check on whether interceptModuleExecution is in use — if interceptors are registered, skip the early throw and let the interceptor handle it.

How is this affecting a real-world project?

Next.js uses interceptModuleExecution in its ReactRefreshWebpackPlugin to detect missing module factories and recover with a page reload:

// If the original factory is missing, e.g. due to race condition
// when compiling multiple entries concurrently, recover by doing
// a full page reload.
'if (!originalFactory) {',
Template.indent('document.location.reload();'),
Template.indent('return;'),
'}',

This handles a legitimate scenario in development: during HMR with concurrent server component rendering, React's Flight protocol can serialize client references from one page that aren't present in another page's webpack module registry. The old behavior allowed the React Refresh interceptor to catch this and reload; the new check makes it a hard error before the interceptor runs.

Link to Minimal Reproduction and step to reproduce

checkout vercel/next.js#89569 which updates webpack for next.js to 5.105

pnpm i
pnpm build
pnpm test-dev-webpack test/development/app-dir/hmr-iframe/hmr-iframe.test.ts

Expected Behavior

the test should continue passing as interception hooks should be able to run before the dev mode missing module check

Actual Behavior

loading a missing module immediately fails with an Error

Environment

- webpack: 5.105.0 (also affects 5.104.0+)
- Node.js: v22.x
- OS: macOS

Is this a regression?

Yes (please specify version below)

Last Working Version

v5.98.0

Additional Context

No response

Activity

  1. bhumika-ks31 commented on Feb 19, 2026

    @bhumika-ks31
    bhumika-ks31
    on Feb 19, 2026
    More actions

    @lukesandberg i fixed this issue review my pr

  2. alexander-akait
    added the
    Bug
    issue type on Feb 19, 2026
  3. khudabox144 commented on Feb 20, 2026

    @khudabox144
    khudabox144
    on Feb 20, 2026
    More actions

    Hi, I’d like to help test this fix or improve coverage. Is there anything missing in the current PR that I can assist with?

  4. shoryax commented on Feb 21, 2026

    @shoryax
    shoryax
    on Feb 21, 2026
    More actions

    I believe this issue hasn’t been taken yet, and I can work on a fix. Could it be assigned to me? @alexander-akait

  5. alexander-akait commented on Feb 21, 2026

    @alexander-akait
    alexander-akait
    on Feb 21, 2026
    Member
    More actions

    You can get any issue if you don't want to use only AI generated code

  6. shoryax commented on Feb 21, 2026

    @shoryax
    shoryax
    on Feb 21, 2026
    More actions

    absolutely, i agree. it's a tool, not something to be dependent on. I'll make sure the implementation is my own. I'll go ahead and get started on this. @alexander-akait

  7. alexander-akait
    closed this as completedin #20510on Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Bug

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.