Skip to content

fix(bff-core): filter failed modules correctly and include filename in errors#8434

Open
KotoriK wants to merge 2 commits intoweb-infra-dev:mainfrom
KotoriK:fix/issue-8421
Open

fix(bff-core): filter failed modules correctly and include filename in errors#8434
KotoriK wants to merge 2 commits intoweb-infra-dev:mainfrom
KotoriK:fix/issue-8421

Conversation

@KotoriK
Copy link

@KotoriK KotoriK commented Mar 10, 2026

Summary

This pull request improves error handling in the BFF module loading process within @modern-js/bff-core. The main changes ensure that modules failing to load are properly filtered out and that error messages include the filename for easier debugging. Tests have been added to validate this behavior in both production and non-production environments.

Error handling improvements

  • Updated getModuleInfos in ApiRouter to correctly filter out failed modules after loading, ensuring only successfully loaded modules are processed.
  • Enhanced error reporting in production: when a module fails to load, the thrown error message now includes the filename, making it easier to identify problematic files.

Testing enhancements

  • Added a fixture module (broken/index.ts) that intentionally throws an error to test error handling, and a valid module for comparison. [1] [2]
  • Added tests to verify that failed modules are filtered out in non-production and that error messages include filenames in production.

Related Links

Fix #8421

Checklist

  • I have added changeset via pnpm run change.
  • I have updated the documentation.
  • I have added tests to cover my changes.

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2026

🦋 Changeset detected

Latest commit: 02427a1

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

This PR includes changesets to release 112 packages
Name Type
@modern-js/bff-core Patch
@modern-js/plugin-bff Patch
bff-api-app Patch
bff-client-app Patch
bff-indep-client-app Patch
bff-hono Patch
deploy-server Patch
pure-esm-project Patch
basic-app-rstest Patch
@modern-js/main-doc Patch
@modern-js/tsconfig Patch
@modern-js/adapter-rstest Patch
@modern-js/builder Patch
@modern-js/plugin-data-loader Patch
@modern-js/plugin-ssg Patch
@modern-js/plugin-styled-components Patch
@modern-js/plugin-i18n Patch
@modern-js/image Patch
@modern-js/runtime Patch
@modern-js/render Patch
@modern-js/bff-runtime Patch
@modern-js/server-core Patch
@modern-js/create-request Patch
@modern-js/plugin-polyfill Patch
@modern-js/prod-server Patch
@modern-js/server-runtime Patch
@modern-js/server Patch
@modern-js/server-utils Patch
@modern-js/app-tools Patch
@modern-js/create Patch
@modern-js/i18n-utils Patch
@modern-js/plugin Patch
@modern-js/runtime-utils Patch
@modern-js/sandpack-react Patch
@modern-js/types Patch
@modern-js/utils Patch
@modern-js/rslib Patch
@modern-js/bundle-diff-benchmark Patch
@scripts/prebundle Patch
@scripts/rstest-config Patch
app-document Patch
ssr-base-async-entry-test Patch
ssr-base-json-test Patch
ssr-base-test Patch
ssr-base-fallback-test Patch
init Patch
ssr-base-loadable Patch
ssr-partial-test Patch
ssr-streaming-inline-test Patch
ssr-streaming-test Patch
styled-components-stream Patch
styled-components-string Patch
basic-app-rstest-browser Patch
rsc-ssr-app Patch
i18n-app-ssr Patch
i18n-mf-app-provider Patch
i18n-mf-component-provider Patch
i18n-mf-consumer Patch
i18n-routes-ssr Patch
ssg-fixtures-mega-list-routes Patch
ssg-fixtures-nested-routes Patch
ssg-fixtures-simple Patch
ssg-fixtures-web-server Patch
i18n-app-csr-html-lang Patch
i18n-app Patch
i18n-app-ssr-html-lang Patch
i18n-custom-i18n-wrapper Patch
i18n-routes Patch
@integration-test/image-component Patch
@integration-test/alias-set Patch
async-entry-test Patch
tmp Patch
integration-clean-dist-path Patch
integration-compatibility Patch
integration-custom-dist-path Patch
custom-file-system-entry Patch
integration-custom-template Patch
deploy Patch
dev-server Patch
integration-disable-html Patch
app-custom-entries Patch
app-custom-routes-runtime Patch
app-custom Patch
app-entry Patch
app-route Patch
app-entry-server Patch
main-entry-name Patch
nonce Patch
routes-match Patch
routes Patch
app-rsbuild-hooks Patch
rsc-csr-app Patch
rsc-csr-routes Patch
rsc-ssr-routes Patch
runtime-custom-plugin Patch
runtime-custom-config-plugin Patch
select-mul-entry-test Patch
select-one-entry-test Patch
server-config Patch
server-json-script Patch
server-monitors Patch
server-prod Patch
server-routes Patch
@source-code-build/app Patch
ssr-script-loading Patch
integration-tailwindcss-v2 Patch
integration-tailwindcss-v3 Patch
integration-tailwindcss-v4 Patch
tmp-dir Patch
write-to-dist Patch
entries-app-builder Patch
@scripts/release-node 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

netlify bot commented Mar 10, 2026

Deploy Preview for modernjs-byted ready!

Name Link
🔨 Latest commit 02427a1
🔍 Latest deploy log https://app.netlify.com/projects/modernjs-byted/deploys/69b0285813baa100082dcaa4
😎 Deploy Preview https://deploy-preview-8434--modernjs-byted.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 94 (🔴 down 3 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

@KotoriK KotoriK closed this Mar 10, 2026
@KotoriK KotoriK deleted the fix/issue-8421 branch March 10, 2026 14:05
@KotoriK KotoriK restored the fix/issue-8421 branch March 10, 2026 14:10
@KotoriK KotoriK reopened this Mar 10, 2026
@KotoriK KotoriK marked this pull request as draft March 10, 2026 14:10
@KotoriK KotoriK changed the title Merge pull request #1 from KotoriK/copilot/fix-issue-8421 fix(bff-core): filter failed modules correctly and include filename in errors Mar 10, 2026
@KotoriK KotoriK marked this pull request as ready for review March 10, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: bff函数加载失败时,给出更好的错误提示

2 participants