feat(runtime): observe preload resource results#4745
Conversation
🦋 Changeset detectedLatest commit: 22a9327 The changes in this PR will be included in the next version bump. This PR includes changesets to release 46 packages
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 |
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/metro-plugin-rock
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/observability-plugin
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08c71a66be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| `preloadRemote` waits for the resources involved in the current preload call to | ||
| finish. The Promise resolves when every resource succeeds or is already cached. | ||
| If any resource fails or times out, the Promise rejects and the error object | ||
| contains the preload resource results. |
There was a problem hiding this comment.
Correct preloadRemote promise semantics
This new contract is inconsistent with the runtime implementation: preloadRemote does not wait for CSS/JS preload completion and does not surface per-resource failure results. In packages/runtime-core/src/remote/index.ts it only awaits snapshot/asset generation and then calls preloadAssets(...); preloadAssets (packages/runtime-core/src/utils/preload.ts) appends <link>/<script> tags with no awaited success/error path, and no code path populates an error.results structure like the example. As written, consumers may incorrectly treat await preloadRemote(...) as a reliable success/failure gate and build retry/error handling that never receives the documented resource-level statuses.
Useful? React with 👍 / 👎.
61ca1c1 to
931caeb
Compare
Description
Add resource-level observability for
preloadRemoteand document how to consume the result.This change makes preload flows easier to inspect:
preloadRemotenow waits for the resource results of the current preload call.loadRemoteorpreloadRemote.Usage Example
Reviewers can use the new behavior directly from the
preloadRemotePromise:Runtime plugins can also use
resourceContextto apply different resource policies:Related Issue
N/A
Types of changes
Checklist
Validation:
pnpm --filter @module-federation/runtime-core exec tsc --noEmit --pretty falsepnpm --filter @module-federation/observability-plugin exec tsc --noEmit --pretty falsepnpm --filter @module-federation/sdk exec tsc --noEmit --pretty falsepnpm --filter @module-federation/runtime-core test -- hooks.spec.tspnpm --filter @module-federation/observability-plugin test -- observability.spec.tspnpm exec prettier --check <changed files>git diff --checkThe commit hook also ran Prettier and package lint for the changed runtime, SDK, and observability packages.