Skip to content

fix(node): enhance error messaging for fetchAndRun with url #3729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nameofname
Copy link
Contributor

Description

I have noticed that when loadRemote fails because fetching a given file is unsuccessful, the URL that was attempted to fetch is not available. See my previous PR which dealt with allowing retries to function properly.

This change to the node runtime plugin will generate a new error, assigning the caught error as the cause. To do so, I added "lib": ["es2022.error"], to the tsconfig for node package. Doing so caused some other ts errors which I resolved.

In addition, I added some unit tests, to assert:

  1. the URL is a part of the error.message
  2. a new test for my previous change in this PR

Example error before :

TestRemote/sample offline SyntaxError: Unexpected token '<'
    at remoteEntry.js:1200:89
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

... not great... Example error after :

TestRemote/sample offline Error: Error while fetching from URL: http://localhost:5555/_next/static/ssr/__federation_expose_sample-57e84cc62a33d51b.js
    at createFetchError (remoteEntry.js:5128:35)
    at remoteEntry.js:5144:22
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: SyntaxError: Unexpected token '<'
      at remoteEntry.js:5141:73
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}

Related Issue

#3685

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.

Copy link

changeset-bot bot commented Apr 25, 2025

🦋 Changeset detected

Latest commit: 73158b2

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

This PR includes changesets to release 32 packages
Name Type
@module-federation/node Minor
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/runtime Patch
@module-federation/enhanced Patch
@module-federation/rspack Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/dts-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/rsbuild-plugin Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/cli Patch
@module-federation/storybook-addon Patch
@module-federation/modernjsapp Patch
@module-federation/esbuild Patch
@module-federation/utilities Patch
remote5 Patch
website-new 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

Copy link

netlify bot commented Apr 25, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 73158b2
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/68148c67c52c800008a93e6c
😎 Deploy Preview https://deploy-preview-3729--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 site configuration.

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.

2 participants