Server never closes when using Metro API
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
Do you want to request a feature or report a bug?
It's a question, actually. 🙏
What is the current behavior?
I'm developing a Node application which uses Metro's API, namely the runServer function. When an app connects to the server to download the bundle and then the server is shutdown after a while, the callback passed to server.close() is never called, even if the app is terminated before that. However, it does get called if I start the server and then shut it down right after, when no app initiates a connection.
const { promisify } = require('util);
const metro = require('metro');
const server = await metro.runServer(myConfig, myOpts);
await promisify(server.close).call(server) // hangs
What is the expected behavior?
My Metro config is pretty much based on the one from React Native's CLI. I've set extraNodeModules and watchFolders options to bundle additional modules dynamically, i.e., paths to the modules provided by the user. I'm not attaching the server to messageSocket and eventsSocket though.
I think the expected behavior here would be Metro to clean up the allocated resources upon a request to close the server.
System:
OS: macOS 10.15.6
CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
Memory: 32.98 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.7.0 - /usr/local/bin/node
npm: 6.14.7 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Packages:
Metro: 0.58.0 (the version that `react-native@0.63.3` depends on)
Contributor guide
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.
Research direction
Start at Metro's runServer API and the server.close lifecycle, reproducing the hang after a client downloads a bundle. Trace the resources that remain active after the client disconnects; done means closing the server completes and allocated resources are released in that sequence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100