-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow waiting for metro to be torn down
Summary: X-link: facebook/react-native#46620 The following error was thrown when the test `packages/metro/src/integration_tests/__tests__/server-test.js` was running on Metro: {F1816961963} It led me to investigate why don't we wait for Metro to be torn down. Currently we close metro by closing the http server that it launches. ``` const httpServer = await Metro.runServer(/* ... */); httpServer.close(callback); ``` While we can listen to the callback fired when the server is closed, it only covers one of the systems running internally in metro. The systems that are not covered are: * File watchers * File map workers * Dependency graph * Bundler And many systems that were themselves listening to the above like "eslint file map" or the "dependency analysis". **These systems are closed by us _after_ the server is closed.** This means that a listener to `server.on('close'` would only get the indication where these systems has started to close rather than actually got closed. https://www.internalfb.com/code/fbsource/[17e03bc6bd86]/xplat/js/tools/metro/packages/metro/src/index.flow.js?lines=359-361 This diff introduces a way to wait for all of metro to be closed. In this diff I use that new way of listening to Metro closure to get rid of the jest test warning mentioned above in `packages/metro/src/integration_tests/__tests__/server-test.js`: ``` let serverClosedPromise; beforeEach(async () => { config = await Metro.loadConfig({ config: require.resolve('../metro.config.js'), }); let onCloseResolve; serverClosedPromise = new Promise(resolve => (onCloseResolve = resolve)); httpServer = await Metro.runServer(config, { reporter: {update() {}}, onClose: () => { onCloseResolve(); }, }); }); afterEach(async () => { httpServer.close(); await serverClosedPromise; }); ``` Changelog: [Feature] add `onClose` to `Metro.runServer` configuration allowing to wait for metro and all associated processes to be closed. Reviewed By: huntie Differential Revision: D61594124 fbshipit-source-id: e3c50ef986077503bce0caa42a9f9430efc65272
- Loading branch information
1 parent
de641a6
commit b3f141f
Showing
16 changed files
with
258 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.