Skip to content

fix(node): report HTTP failures before evaluating remote scripts#4811

Open
dmchoi77 wants to merge 4 commits into
module-federation:mainfrom
dmchoi77:fix/node-remote-http-status-errors
Open

fix(node): report HTTP failures before evaluating remote scripts#4811
dmchoi77 wants to merge 4 commits into
module-federation:mainfrom
dmchoi77:fix/node-remote-http-status-errors

Conversation

@dmchoi77

Copy link
Copy Markdown

Description

This fixes Node.js remote script loading paths so non-ok HTTP responses are reported before their response bodies are evaluated as JavaScript.

Previously, when a Node remote entry or federated runtime chunk returned an HTTP error response such as 404 or 503, the loader could read the response body and attempt to evaluate it as JavaScript. That could surface a confusing syntax error such as Unexpected identifier instead of the actual HTTP failure.

This change:

  • Adds HTTP status validation before evaluating Node remote entry responses in @module-federation/sdk.
  • Adds HTTP status validation before evaluating fetched federated chunks in @module-federation/node.
  • Preserves diagnostic context for chunk loading failures, including chunk name, URL, host, resolution metadata, HTTP status, and response preview.
  • Adds regression tests for non-ok remote entry and chunk responses.
  • Adds a patch changeset for @module-federation/sdk and @module-federation/node.

Tested with Node.js v20.19.5:

  • corepack pnpm --filter @module-federation/sdk run test
  • corepack pnpm --filter @module-federation/node run test
  • corepack pnpm --filter @module-federation/sdk run build
  • corepack pnpm --filter @module-federation/node run build
  • corepack pnpm --filter @module-federation/sdk run lint
  • corepack pnpm --filter @module-federation/node run lint
  • corepack pnpm exec prettier --check packages/sdk/src/node.ts packages/sdk/__tests__/node-http-status.spec.ts packages/node/src/runtimePlugin.ts packages/node/src/__tests__/runtimePlugin.test.ts .changeset/quiet-node-loader-status.md

Related Issue

Fixes #4810

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot

changeset-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 241c892

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

This PR includes changesets to release 46 packages
Name Type
@module-federation/sdk Patch
@module-federation/node Patch
@module-federation/devtools Patch
@module-federation/cli Patch
@module-federation/dts-plugin Patch
@module-federation/enhanced Patch
@module-federation/esbuild Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/metro Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/observability-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspack Patch
@module-federation/rspress-plugin Patch
@module-federation/runtime-core Patch
@module-federation/runtime Patch
@module-federation/storybook-addon Patch
@module-federation/utilities Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/runtime-tools Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/bridge-shared Patch
@module-federation/error-codes Patch
create-module-federation Patch
@module-federation/treeshake-server Patch
@module-federation/treeshake-frontend 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

@netlify

netlify Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 241c892
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/6a3a9dade7a14700089e6067
😎 Deploy Preview https://deploy-preview-4811--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@4c2858e

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@4c2858e

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@4c2858e

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@4c2858e

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@4c2858e

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@4c2858e

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@4c2858e

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@4c2858e

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@4c2858e

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@4c2858e

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@4c2858e

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@4c2858e

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rock@4c2858e

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@4c2858e

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@4c2858e

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@4c2858e

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@4c2858e

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@4c2858e

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@4c2858e

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@4c2858e

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@4c2858e

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@4c2858e

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@4c2858e

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@4c2858e

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@4c2858e

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@4c2858e

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@4c2858e

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@4c2858e

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@4c2858e

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@4c2858e

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@4c2858e

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@4c2858e

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@4c2858e

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@4c2858e

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@4c2858e

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@4c2858e

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@4c2858e

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@4c2858e

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@4c2858e

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@4c2858e

commit: 4c2858e

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Report

16 package(s) changed, 25 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-react 379.5 kB +2.8 kB (+0.8%) 1.3 kB -3 B (-0.2%)
@module-federation/bridge-vue3 172.9 kB +1.3 kB (+0.8%) 25.2 kB +263 B (+1.0%)
@module-federation/cli 26.3 kB no change 786 B no change
@module-federation/core 39.1 kB no change 173 B no change
@module-federation/devtools 664.0 kB no change 4.0 kB no change
@module-federation/enhanced 809.2 kB no change 672 B no change
@module-federation/inject-external-runtime-core-plugin 5.2 kB -26 B (-0.5%) 519 B no change
@module-federation/managers 69.8 kB no change 334 B no change
@module-federation/manifest 136.1 kB no change 182 B no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/node 198.7 kB +5.3 kB (+2.7%) 217 B no change
@module-federation/runtime-core 287.4 kB -8 B (-0.0%) 477 B no change
@module-federation/runtime-tools 7.8 kB +65 B (+0.8%) 142 B no change
@module-federation/sdk 124.1 kB +2.8 kB (+2.3%) 785 B no change
@module-federation/storybook-addon 79.1 kB no change 100 B no change
@module-federation/utilities 110.6 kB no change 328 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-react 17.9 kB no change 18.5 kB +220 B (+1.2%)
@module-federation/bridge-vue3 18.9 kB no change 18.9 kB +220 B (+1.1%)
@module-federation/cli 2.3 kB -29 B (-1.2%) 2.3 kB -29 B (-1.2%)
@module-federation/core 1.1 kB -30 B (-2.7%) 1.0 kB -29 B (-2.7%)
@module-federation/devtools 30.2 kB -30 B (-0.1%) 30.2 kB -30 B (-0.1%)
@module-federation/enhanced 2.6 kB -43 B (-1.6%) 2.6 kB -43 B (-1.6%)
@module-federation/inject-external-runtime-core-plugin 396 B no change 396 B no change
@module-federation/managers 2.4 kB -26 B (-1.0%) 2.4 kB -26 B (-1.0%)
@module-federation/manifest 6.1 kB -39 B (-0.6%) 6.1 kB -39 B (-0.6%)
@module-federation/metro-plugin-rnc-cli 411 B -25 B (-5.7%) 411 B -25 B (-5.7%)
@module-federation/node 9.2 kB -27 B (-0.3%) 9.2 kB -27 B (-0.3%)
@module-federation/runtime-core 15.2 kB no change 15.0 kB no change
@module-federation/runtime-tools 89 B no change 89 B no change
@module-federation/sdk 4.5 kB no change 5.6 kB +229 B (+4.2%)
@module-federation/storybook-addon 1.9 kB -24 B (-1.2%) 1.7 kB -24 B (-1.3%)
@module-federation/utilities 2.6 kB -31 B (-1.2%) 2.6 kB -31 B (-1.2%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 21.4 kB -15 B (-0.1%) 22.7 kB +206 B (+0.9%) +1.3 kB +221 B

Total dist (raw): 6.83 MB (+12.3 kB (+0.2%))
Total ESM gzip: 78.8 kB (+260 B (+0.3%))
Total web bundle (gzip): 207.1 kB (-304 B (-0.1%))
Total node bundle (gzip): 208.2 kB (+366 B (+0.2%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.8 kB (no change)
Tracked ./bundler node bundle (gzip): 4.8 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node loaders evaluate non-ok HTTP responses as JavaScript

2 participants