observability-plugin: shared-dependency hooks do full diagnostic work on the startup path at summary level, with no opt-out
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript, react, typescript, webpack
- Domain
- backend-api-design, observability, performance
Research direction
Start by tracing afterRegisterShare, initContainerShareScopeMap, resolveShare, beforeLoadShare, and afterLoadShare into recordEvent and the event notification functions; the issue does not name source files or tests. Compare the proposed opt-out and level-check approaches, then locate the existing tests for shared hooks and event reporting. Done means shared success-path work can be disabled or avoided at summary level while singleton conflict detection and shared-load failures still report correctly.
Written by the indexing model from the issue text.
Description
Versions: @module-federation/observability-plugin 2.6.2, @module-federation/runtime-core 2.9.2, browser host
What happens
afterRegisterShareandinitContainerShareScopeMapcallrecordSharedRegistrationonce for every shared package version in every container. Each call runscreateSharedRegistrationInfo, which builds the candidate list (a semversatisfiesper candidate) and sanitizes strings with the URL and secret regexes. Each registration also gets a uniqueshared-register-Nrequest id, soresolveTraceIdcreates a new trace and report for every one.- On every
loadShare/loadShareSync,resolveSharewraps the resolver to build a full selection (candidates plus semver checks).afterLoadSharethen records asuccessevent. recordEventrunsnormalizeEvent,applyPhaseDurationandupdateTraceMapsbefore it checksshouldRecordEvent.summarydrops onlystartevents, so thesesuccessevents are fully recorded.- Every recorded event is deep-copied twice:
notifyEventcopies the event and the report, thennotifyReportcopies the report again. Each copy is a spread followed by a recursiveObject.entriesclone.
All of this runs synchronously during container init and shared resolution, before the first remote renders. It runs even when nothing reads shared-registration or shared-resolution data. summary is the default level, and onEvent / onReport are commonly set for load and error telemetry.
Impact
We tested a host with dozens of shared packages and a few remotes, using 30 paired cold loads on one machine and network. Removing the success-path shared hooks shortened time to first remote render by:
- ~25 ms (median) at native CPU speed
- ~70 ms (median) with 2× CPU throttling
In a CPU profile, recordSharedRegistration was the largest single cost inside the plugin.
Proposals
- Add a factory option alongside
disablePreloadHooks, e.g.disableSharedHooks, or a finersharedAudit: 'all' | 'errors'. It would skipafterRegisterShare,initContainerShareScopeMap,resolveShare,beforeLoadShareandafterLoadShare. It would keepbeforeRegisterShare(singleton version-conflict detection) anderrorLoadShare(shared load failures). - In
recordEvent, check the level before building the event. Better still, let hooks skip buildingsharedinfo when the event would be dropped. - Copy the report once per event and pass the same copy to
onEventandonReport.
Workaround
runtime-core registers a hook only when its value is truthy, so wrap the plugin and clear the keys. Clear them on the apply() result as well, because it takes precedence:
const DROPPED = {
afterRegisterShare: undefined,
initContainerShareScopeMap: undefined,
resolveShare: undefined,
beforeLoadShare: undefined,
afterLoadShare: undefined,
};
const { plugin } = createObservability(options, factoryOptions);
const { apply } = plugin;
const filtered = {
...plugin,
...DROPPED,
apply: apply && (instance => {
const hooks = apply(instance);
return hooks && { ...hooks, ...DROPPED };
}),
};
errorLoadShare still reports failures with their reason in this setup, because ensureSharedLoadContext creates the operation context when beforeLoadShare didn't run.
Related: #5110 reduces the plugin's bundle size; this issue is about runtime work on the startup path.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 441
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from module-federation/core
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
module-federation/core#5205 · 4 comments · 3 reactions ·
Maintainers usually reply within 1 day
-
@module-federation/enhanced fails to load with webpack 5.112.0: Cannot find module 'webpack/lib/util/extractUrlAndGlobal'Possibly taken @lnuvy claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
module-federation/core#5202 · 1 comment · 8 reactions ·
Maintainers usually reply within 1 day
-
Runtime mistakes existing globals for remote containers and can remove them on retryPossibly taken @tonoizer claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 20/100
module-federation/core#5222 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
module-federation/core#5210 ·
Maintainers usually reply within 1 day
-
Container init deadlock with cyclic remotesPossibly taken @Noyabronok claimed this 19 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
module-federation/core#5196 · 1 comment ·
Maintainers usually reply within 1 day
All issues in module-federation/core
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
mongoosejs/mquery#142 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Add toro4n to the data modeling toolsPossibly taken @henriklantzhedstrom-prog claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 62/100
neo4j/docs-getting-started#546 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 25 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libnativeapi/nativeapi#21 ·