Skip to content

fix(enhanced): add runtime safety checks to prevent errors #3900

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

Merged
merged 8 commits into from
Jul 15, 2025

Conversation

ScriptedAlchemy
Copy link
Member

Summary

  • Add defensive checks to prevent runtime errors when expected functions don't exist
  • First PR from the incremental plan to break up the massive enhanced package changes

Changes

  1. EmbedFederationRuntimeModule.ts: Added typeof oldStartup === 'function' check before calling oldStartup()
  2. StartupHelpers.ts: Added typeof __webpack_require__.x === "function" check before calling webpack_require.x()

Why

These defensive checks prevent runtime errors when expected functions don't exist in certain build configurations. This improves stability and prevents edge case failures.

Test Plan

  • Code changes are minimal and defensive
  • Existing tests pass
  • No breaking changes introduced

Related

  • Part of the incremental PR plan documented in INCREMENTAL_PR_PLAN_REVISED.md
  • Extracted from the larger share-filter branch changes

🤖 Generated with Claude Code

Copy link

changeset-bot bot commented Jul 11, 2025

🦋 Changeset detected

Latest commit: f184f46

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

This PR includes changesets to release 33 packages
Name Type
@module-federation/enhanced Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/storybook-addon Patch
@module-federation/modernjsapp Patch
remote5 Patch
website-new Patch
@module-federation/runtime 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/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/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

Copy link

netlify bot commented Jul 11, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit f184f46
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/6876a84c15cba60008808e31
😎 Deploy Preview https://deploy-preview-3900--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.

- Add typeof check for oldStartup function in EmbedFederationRuntimeModule
  - Log warning when oldStartup is not a function
- Add typeof check for __webpack_require__.x in StartupHelpers
  - Log warning when __webpack_require__.x is not a function

These defensive checks prevent runtime errors when expected functions
don't exist in certain build configurations. The warnings help developers
debug issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ScriptedAlchemy ScriptedAlchemy force-pushed the fix/runtime-safety-checks branch from d8773d7 to 9d5ace9 Compare July 12, 2025 04:19
ScriptedAlchemy added a commit that referenced this pull request Jul 12, 2025
Created a detailed plan to split the massive changes in packages/enhanced
into 12 focused, incremental PRs:
- Runtime safety fixes (COMPLETED - PR #3900)
- Hook renaming refactor
- Container hoisting improvements
- Share filtering features (broken into 4 sub-features)
- Layer support enhancements
- API exports and test coverage

Each PR is self-contained with clear dependencies documented.

Also added worktrees/ to .gitignore

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
ScriptedAlchemy and others added 4 commits July 11, 2025 21:23
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Renamed variable from oldStartup to prevStartup in EmbedFederationRuntimeModule
- Updated all references including typeof checks and console warnings
- Updated documentation files to reflect the improved naming
@ScriptedAlchemy ScriptedAlchemy merged commit 1825b9d into main Jul 15, 2025
17 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the fix/runtime-safety-checks branch July 15, 2025 19:53
@2heal1 2heal1 mentioned this pull request Jul 24, 2025
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