Container init deadlock with cyclic remotes
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, typescript, webpack
- Domain
- backend-api-design
Research direction
Start by tracing initializeSharing in the webpack-bundler-runtime and compare how its pending init promise interacts with the initScope cycle guard. Use the linked reproduction at https://github.com/Noyabronok/mf2-init-deadlock-repro (npm install, then npm start) to reproduce the hang; the README trace and DEBUG=1 npm start identify the init sequence. Done means both imports settle for the cyclic remotes with the default version-first strategy, with regression tests covering the deadlock.
Written by the indexing model from the issue text.
Description
Describe the bug
Two remotes that list each other as remotes and declare a shared entry can deadlock during container init in @module-federation/enhanced (tested with the latest 2.9.2 on webpack). If a host imports both while the first remote's init is still loading the second remote's entry, both import()s stay pending forever and no error is thrown.
It happens with the default version-first strategy on the remotes, and sharing react deadlocks the same way. Setting shareStrategy: 'loaded-first' on both remotes avoids it.
The cause is in webpack-bundler-runtime's initializeSharing. It returns a container's pending init promise to any caller, and the initScope cycle guard only sees the caller's own chain. When the host's chain and a remote's chain each enter one of the two containers, each waits on the other's pending promise and neither settles.
I'll open a PR with this fix and tests.
Reproduction
https://github.com/Noyabronok/mf2-init-deadlock-repro
npm install
npm start
http://localhost:3000/?gap=100 hangs (both imports log still pending after 5s: DEADLOCK), http://localhost:3000/?gap=2000 resolves. DEBUG=1 npm start adds a debug plugin that logs each container init, and the README has the full trace.
Used Package Manager
npm
System Info
System:
OS: macOS 26.6.2
CPU: (10) arm64 Apple M1 Max
Memory: 84.50 MB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.21.0
npm: 11.19.0
Browsers:
Chrome: 155.0.8059.40
npmPackages:
@module-federation/enhanced: 2.9.2
webpack: 5.110.3
webpack-cli: 7.2.3
Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Module federation issue and not a framework-specific issue.
- The provided reproduction is a minimal reproducible example of the bug.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 441
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 32
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 · 2 comments · 2 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 2 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
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
module-federation/core#5210 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
module-federation/core#5204 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
module-federation/core#5195 ·
Maintainers usually reply within 1 day
All issues in module-federation/core
Similar issues
-
external-plugin ready-for-review third party
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/awesome-copilot#5713 · 1 comment ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
carbon-design-system/carbon-react-router-starter#1005 ·
Maintainers usually reply within 1 day
-
enhancement p2 setup
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Query Log shows "Upstream" for CNAME cloaking, schedule, NXDOMAIN hijack and response IP blocksOpenbug good first issue query-log web
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ferrous-networking/ferrous-dns#326 ·
Maintainers usually reply within 1 day