Skip to content

feat(runtime): add loadEntryTimeout option for the remote entry script timeout - #5035

Open
marksnode wants to merge 1 commit into
module-federation:mainfrom
marksnode:feat/load-entry-timeout
Open

marksnode wants to merge 1 commit into
module-federation:mainfrom
marksnode:feat/load-entry-timeout

Conversation

@marksnode

@marksnode marksnode commented Sep 5, 2026

Copy link
Copy Markdown

Description

createScript in @module-federation/sdk hard-codes the remote entry load timeout to 20 s, and the only way to change it is a createScript runtime hook that returns { script, timeout }. Remotes behind a slow proxy or a congested staging cluster regularly need more than that and fail with RUNTIME-008 ... timed out even though the download finishes a few seconds later.

This adds a first-class loadEntryTimeout runtime option (ms) that flows into the script timer, keeping the createScript hook as the per-URL override.

  • @module-federation/sdk (dom.ts): createScript and loadScript accept timeout; a positive number replaces the 20 s default (DEFAULT_SCRIPT_TIMEOUT), a createScript hook return value still wins, and a non-finite value (Infinity) skips the timer.
  • @module-federation/runtime-core:
    • Options.loadEntryTimeout?: number (so it is also part of UserOptions for init / createInstance).
    • getRemoteEntryloadEntryDomloadEntryScript pass origin.options.loadEntryTimeout to loadScript.
    • preload.ts waitForScriptPreload passes host.options.loadEntryTimeout to createScript, so preloaded entries use the same budget.
    • SnapshotHandler.getManifestJson bounds the manifest fetch (mf-manifest.json) with the same option: when loadEntryTimeout is set, the fetch call (and the fetch loader hook) receive an AbortSignal that fires after the timeout. Today that request is fetch(url, {}) with no timeout at all, so a stalled manifest response holds loadRemote open indefinitely — the entry script has a 20 s budget, the manifest that names it has none. Left unbounded when the option is not set, so default behaviour does not change.
    • SnapshotHandler.getManifestJson bounds the manifest fetch (mf-manifest.json) with the same option: when loadEntryTimeout is set, the fetch call (and the fetch loader hook) receive an AbortSignal that fires after the timeout. Today that request is fetch(url, {}) with no timeout at all, so a stalled manifest response holds loadRemote open indefinitely — the entry script has a 20 s budget, the manifest that names it has none. Left unbounded when the option is not set, so default behaviour does not change.
  • Tests: sdk/__tests__/dom.spec.ts (passed timeout, hook precedence, Infinity disables the timer); runtime-core/__tests__/load.spec.ts (loadEntryTimeout reaches the script timer; Infinity arms no timer). runtime-core/__tests__/snapshot.spec.ts (the manifest fetch carries an AbortSignal and arms the timer only when the option is set). runtime-core/__tests__/snapshot.spec.ts (the manifest fetch carries an AbortSignal and arms the timer only when the option is set).
  • Docs: runtime-api.mdx (en/zh) — option described under createInstance.
  • Changeset: patch for @module-federation/sdk and @module-federation/runtime-core.

Related Issue

Closes #5034.

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 855e6d8

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

This PR includes changesets to release 48 packages
Name Type
@module-federation/sdk Patch
@module-federation/runtime-core 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/node 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/rstest 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
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
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
@module-federation/playground Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/runtime-tools Patch
@module-federation/inject-external-runtime-core-plugin Patch
create-module-federation Patch
@module-federation/error-codes Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/treeshake-frontend Patch
@module-federation/treeshake-server Patch
@module-federation/bridge-shared 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

@marksnode
marksnode force-pushed the feat/load-entry-timeout branch from dc84253 to 855e6d8 Compare September 6, 2026 21:02
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.

[Feature]: make the remote entry script timeout configurable without a createScript hook

1 participant