Skip to content

fix(runtime-core): improve error messages clarity and fix preload resourceCategory bug#4502

Merged
2heal1 merged 11 commits intomainfrom
feat/enhanced-error-messages
Mar 13, 2026
Merged

fix(runtime-core): improve error messages clarity and fix preload resourceCategory bug#4502
2heal1 merged 11 commits intomainfrom
feat/enhanced-error-messages

Conversation

@2heal1
Copy link
Copy Markdown
Member

@2heal1 2heal1 commented Mar 5, 2026

fix(runtime-core): improve error messages clarity and fix preload resourceCategory bug

Summary

Reviewed and improved error messages across packages/runtime-core to make failures
easier to diagnose for both developers and AI agents. Also fixed a silent logic bug
in the preload asset generation path.

Bug Fix

plugins/generate-preload-assets.ts: Assignment operator = was used instead of
strict equality === in the resourceCategory branch check. This caused the condition
to always be truthy and silently overwrite preloadConfig.resourceCategory to 'sync'
for every non-'all' entry, resulting in incorrect preload asset selection with no error
reported.

- } else if ((preloadConfig.resourceCategory = 'sync')) {
+ } else if (preloadConfig.resourceCategory === 'sync') {

Error Message Improvements

utils/load.ts

  • ESM entry load failure (loadEsmEntry): bare reject(e) in catch now includes the
    entry URL and original error message.
  • SystemJS entry load failure (loadSystemJsEntry): same as above.
  • Node.js entry load failure (loadEntryNode): bare throw e now includes remote name
    and entry URL.
  • All three use error() from logger.ts so the [ Federation Runtime ] prefix is
    applied consistently.

plugins/snapshot/SnapshotHandler.ts

  • RUNTIME_007: args previously passed hostName: moduleInfo.name (which is actually
    the remote name) and omitted the actual host. Now correctly passes remoteName,
    remoteVersion, and hostName separately so the error context is unambiguous.
  • Manifest structure validation (assert): replaced the generic
    "${url} is not a federation manifest" message with one that names the remote and
    lists exactly which required fields (metaData, exposes, shared) are missing.

shared/index.ts

  • loadShare assertion: message now quotes the package name and host name, and provides
    an actionable hint about where to declare the shared config.
  • initRemoteModule: when errorLoadRemote hook returns undefined (no plugin handled
    the error), the function now returns early instead of falling into the finally block
    with an undefined remoteEntryExports, which previously caused a silent no-op or
    potential Cannot read properties of undefined crash.

utils/share.ts

  • formatShare — missing get/lib error: now includes the package name and source
    module (from) so it's clear which share registration is misconfigured.
  • formatShareeager + treeShaking conflict: now includes the package name and
    source module instead of a generic string.
  • Both use error() from logger.ts for consistent prefix handling.

global.ts

  • getInfoWithoutType: generic 'key must be string' replaced with the actual type
    and serialised value of the bad argument.

remote/index.ts

  • removeRemote: logger.log(...) (info-level) changed to logger.error(...) so the
    failure surfaces at the correct severity level.

Testing

All changes are confined to error paths (catch blocks, assertions, and branch conditions).
The preload bug fix restores the originally intended sync-only asset filtering behavior.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: 490b067

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

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

netlify bot commented Mar 5, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 5600d80
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69b0e69bc0fde30008e53df9
😎 Deploy Preview https://deploy-preview-4502--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 5, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@2bcc444

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@2bcc444

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@2bcc444

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/@module-federation/data-prefetch@2bcc444

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@2bcc444

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@2bcc444

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@2bcc444

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@2bcc444

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@2bcc444

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@2bcc444

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@2bcc444

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@2bcc444

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@2bcc444

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@2bcc444

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@2bcc444

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@2bcc444

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@2bcc444

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@2bcc444

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@2bcc444

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@2bcc444

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@2bcc444

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@2bcc444

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@2bcc444

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@2bcc444

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@2bcc444

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

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

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@2bcc444

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@2bcc444

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@2bcc444

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@2bcc444

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@2bcc444

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

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

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@2bcc444

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@2bcc444

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

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

commit: 2bcc444

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 5, 2026

Bundle Size Report

18 package(s) changed, 23 unchanged.

Package dist + public ESM exports

Package Total dist (raw) Delta Public ESM gzip Delta
@changesets/assemble-release-plan 26.1 kB -24812 B (-48.1%) 6.6 kB no change
@module-federation/bridge-react 358.2 kB +586 B (+0.2%) 7.3 kB -10 B (-0.1%)
@module-federation/bridge-vue3 142.2 kB +1.6 kB (+1.1%) 21.8 kB +281 B (+1.3%)
@module-federation/cli 26.7 kB no change 786 B no change
@module-federation/core 39.1 kB no change 173 B no change
@module-federation/devtools 4.80 MB -5564 B (-0.1%) 0 B no change
@module-federation/enhanced 841.5 kB no change 1.8 kB no change
@module-federation/inject-external-runtime-core-plugin 5.4 kB -26 B (-0.5%) 548 B no change
@module-federation/managers 70.0 kB no change 334 B no change
@module-federation/manifest 138.4 kB no change 182 B no change
@module-federation/metro 243.9 kB no change 1.6 kB no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/modern-js 183.6 kB no change 11.8 kB no change
@module-federation/modern-js-v3 175.2 kB no change 11.3 kB no change
@module-federation/node 188.4 kB no change 4.6 kB no change
@module-federation/runtime-core 251.2 kB +1.9 kB (+0.8%) 509 B no change
@module-federation/storybook-addon 76.5 kB no change 1.1 kB 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
@changesets/assemble-release-plan 3.1 kB no change 3.1 kB no change
@module-federation/bridge-react 19.3 kB +34 B (+0.2%) 19.8 kB +35 B (+0.2%)
@module-federation/bridge-vue3 16.8 kB +229 B (+1.4%) 17.4 kB +210 B (+1.2%)
@module-federation/cli 2.3 kB -35 B (-1.5%) 2.3 kB -35 B (-1.5%)
@module-federation/core 1.1 kB -34 B (-3.0%) 1.0 kB -32 B (-3.0%)
@module-federation/devtools n/a n/a n/a n/a
@module-federation/enhanced 6.3 kB -62 B (-1.0%) 6.3 kB -62 B (-1.0%)
@module-federation/inject-external-runtime-core-plugin 405 B no change 405 B no change
@module-federation/managers 2.4 kB -28 B (-1.1%) 2.4 kB -28 B (-1.1%)
@module-federation/manifest 6.2 kB -40 B (-0.6%) 6.2 kB -40 B (-0.6%)
@module-federation/metro 11.4 kB -55 B (-0.5%) 11.4 kB -54 B (-0.5%)
@module-federation/metro-plugin-rnc-cli 411 B -27 B (-6.2%) 411 B -27 B (-6.2%)
@module-federation/modern-js 7.0 kB -28 B (-0.4%) 7.0 kB -28 B (-0.4%)
@module-federation/modern-js-v3 6.8 kB -26 B (-0.4%) 6.8 kB -26 B (-0.4%)
@module-federation/node 13.2 kB -32 B (-0.2%) 13.1 kB -43 B (-0.3%)
@module-federation/runtime-core 13.8 kB +237 B (+1.7%) 13.5 kB +210 B (+1.5%)
@module-federation/storybook-addon 2.4 kB -26 B (-1.1%) 2.2 kB -25 B (-1.1%)
@module-federation/utilities 2.6 kB -34 B (-1.3%) 2.6 kB -34 B (-1.3%)

Total dist (raw): 10.67 MB (-26285 B (-0.2%))
Total ESM gzip: 118.5 kB (+271 B (+0.2%))
Total web bundle (gzip): 195.6 kB (+73 B (+0.0%))
Total node bundle (gzip): 197.0 kB (+21 B (+0.0%))

Bundle sizes are generated with rslib (Rspack). Public ESM gzip aggregates explicit package export entry files (wildcard exports are ignored). Web/node bundles synthesize a single entry that imports those public ESM exports, set ENV_TARGET, and enable tree-shaking. Bare imports are externalized to keep sizes consistent with prior reporting, and assets are emitted as resources.

@2heal1 2heal1 merged commit 0ff97d6 into main Mar 13, 2026
20 checks passed
@2heal1 2heal1 deleted the feat/enhanced-error-messages branch March 13, 2026 08:09
@2heal1 2heal1 mentioned this pull request Mar 14, 2026
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.

4 participants