Skip to content

Node loaders evaluate non-ok HTTP responses as JavaScript #4810

Description

@dmchoi77

Describe the bug

When a Node.js remote entry or federated runtime chunk returns a non-ok HTTP response, the loader reads the response body and evaluates it as JavaScript.

For example, if a remote entry or chunk URL returns a 404/503 text response, the reported error can become a JavaScript syntax error such as Unexpected identifier instead of the actual HTTP failure.

I intend to submit a PR for this issue.

Expected behavior:
The Node loaders should detect non-ok HTTP responses before evaluation and report an error that includes the HTTP status and URL.

Actual behavior:
The non-ok response body can be evaluated as JavaScript, which hides the original HTTP failure behind a syntax/evaluation error.

Reproduction

https://github.com/dmchoi77/module-federation-node-http-error-repro

Used Package Manager

pnpm

System Info

System:
  OS: macOS 26.5.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 1.03 GB / 32.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 20.19.5 - /Users/dmchoi/.nvm/versions/node/v20.19.5/bin/node
  npm: 10.8.2 - /Users/dmchoi/.nvm/versions/node/v20.19.5/bin/npm
  pnpm: 10.28.0 - /usr/local/bin/pnpm
  Watchman: 2022.09.19.00 - /usr/local/bin/watchman
Browsers:
  Chrome: 149.0.7827.103
  Safari: 26.5

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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