Plugin change detection is unreliable on Windows VM
Summary:
On Windows VM when "yarn start" is executed and compilation is in progress for some plugin, fs.watch randomly fires "changed" events for different files of other plugins. This leads to infinite attempts to rebuild the same plugin again and again, and this process never ends, so "yarn start" is almost unusable:
{F225467225}
I've tried to fix this by using watchman instead of fs.watch and on my tests with Windows build it works well:
{F225467508}
Also as watchman is more careful about opening file handles, hopefully this change will fix "too many files opened" problem as Michel suggested here https://fb.workplace.com/groups/flippersupport/permalink/764157990731528/ and here https://github.com/facebook/flipper/issues/699.
Reviewed By: mweststrate
Differential Revision: D19216026
fbshipit-source-id: acc53ae0d003a7936730e6423ac4dbca84f089c8
This commit is contained in:
committed by
Facebook Github Bot
parent
477de3e9ba
commit
fa7f970266
@@ -66,7 +66,7 @@ function compile(buildFolder, entry) {
|
||||
),
|
||||
},
|
||||
resolver: {
|
||||
blacklistRE: /\/(sonar|flipper|flipper-public)\/(dist|doctor)\/|(\.native\.js$)/,
|
||||
blacklistRE: /(\/|\\)(sonar|flipper|flipper-public)(\/|\\)(dist|doctor)(\/|\\)|(\.native\.js$)/,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ const http = require('http');
|
||||
const path = require('path');
|
||||
const Metro = require('../static/node_modules/metro');
|
||||
const fs = require('fs');
|
||||
const Watchman = require('../static/watchman');
|
||||
|
||||
const convertAnsi = new Convert();
|
||||
|
||||
@@ -67,7 +68,7 @@ function startMetroServer(app) {
|
||||
),
|
||||
},
|
||||
resolver: {
|
||||
blacklistRE: /\/(sonar|flipper|flipper-public)\/(dist|doctor)\/|(\.native\.js$)/,
|
||||
blacklistRE: /(\/|\\)(sonar|flipper|flipper-public)(\/|\\)(dist|doctor)(\/|\\)|(\.native\.js$)/,
|
||||
},
|
||||
watch: true,
|
||||
}).then(metroBundlerServer => {
|
||||
@@ -114,7 +115,7 @@ function startAssetServer(port) {
|
||||
});
|
||||
}
|
||||
|
||||
function addWebsocket(server) {
|
||||
async function addWebsocket(server) {
|
||||
const io = socketIo(server);
|
||||
|
||||
// notify connected clients that there's errors in the console
|
||||
@@ -126,9 +127,17 @@ function addWebsocket(server) {
|
||||
|
||||
// refresh the app on changes to the src folder
|
||||
// this can be removed once metroServer notifies us about file changes
|
||||
fs.watch(path.join(__dirname, '..', 'src'), () => {
|
||||
io.emit('refresh');
|
||||
});
|
||||
const watchman = new Watchman(path.resolve(__dirname, '..', 'src'));
|
||||
await watchman.initialize();
|
||||
await watchman.startWatchFiles(
|
||||
'/',
|
||||
resp => {
|
||||
io.emit('refresh');
|
||||
},
|
||||
{
|
||||
excludes: ['**/__tests__/**/*', '**/node_modules/**/*', '**/.*'],
|
||||
},
|
||||
);
|
||||
|
||||
return io;
|
||||
}
|
||||
@@ -186,7 +195,7 @@ function outputScreen(socket) {
|
||||
(async () => {
|
||||
const port = await detect(DEFAULT_PORT);
|
||||
const {app, server} = await startAssetServer(port);
|
||||
const socket = addWebsocket(server);
|
||||
const socket = await addWebsocket(server);
|
||||
await startMetroServer(app);
|
||||
outputScreen(socket);
|
||||
launchElectron({
|
||||
|
||||
Reference in New Issue
Block a user