This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
Fix: watch local modules other bundles, 5.x.x #1368
Closed
Closed
Conversation
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
Size Change: 0 B Total Size: 694 kB ℹ️ View Unchanged
|
PixnBits
commented
Apr 4, 2024
@@ -17,54 +17,165 @@ | |||
// This file is only used in development so importing devDeps is not an issue | |||
/* eslint "import/no-extraneous-dependencies": ["error", {"devDependencies": true}] */ | |||
|
|||
import fs from 'fs'; | |||
import path from 'path'; | |||
import chokidar from 'chokidar'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is the only place chokidar is used (directly), can we remove it from package.json?
PixnBits
commented
Apr 4, 2024
PixnBits
commented
Apr 4, 2024
Comment on lines
90
to
105
// this may be an over-optimization in that it may be more overhead than it saves | ||
const stating = new Map(); | ||
function stat(filePath) { | ||
if (!stating.has(filePath)) { | ||
stating.set( | ||
filePath, | ||
fs.stat(filePath) | ||
.then((fileStat) => { | ||
stating.delete(filePath); | ||
return fileStat; | ||
}) | ||
); | ||
} | ||
|
||
watcher.on('change', async (changedPath) => { | ||
try { | ||
if (!changedPath.endsWith('.node.js')) return; | ||
return stating.get(filePath); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too much? (remove?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed in 7398793
This comment was marked as resolved.
This comment was marked as resolved.
e.g. https://forums.docker.com/t/file-system-watch-does-not-work-with-mounted-volumes/12038/5\?page\=2 CHOKIDAR_USEPOLLING not reliable either somehow
inconsistentcies in the event loop evaluation, so switched to manual timer mocks
PixnBits
force-pushed
the
fix/watchLocalModules-other-bundles_5.x.x
branch
from
April 4, 2024 19:12
7398793
to
acefc8f
Compare
14 tasks
rather than string templates, for performance
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
During development use filesystem polling to detect modules being built and then reload them in the running server. This increases the filesystem and CPU usage, but is much more reliable.
This also adds some log entries for the user to know when a module was reloaded, removing guesswork.
Some unnecessary disk reads (module map) were removed.
Motivation and Context
Users are hitting development scenarios where new builds of modules are not detected and then not reloaded in the running server. The limitations of the Node.js built-in API are important, but are smoothed over by chokidar. However, even chokidar is not accurately emiting events, sometimes due to superseding situations like the modules being docker volume mounts, e.g. https://forums.docker.com/t/file-system-watch-does-not-work-with-mounted-volumes/12038.
How Has This Been Tested?
I've both
$ npm serve-module some-module
and run the serverBefore these changes running on metal would occasionally miss the file writing finishing and not reload, and running in a docker container every change after the first build would be missed. After the changes in this PR I saw every write finish detected.
Types of Changes
Checklist:
What is the Impact to Developers Using One App?
Increased confidence when changes are loaded, and end (or at the very least, greatly decrease) the users having to restart the one-app server to see server bundle changes loaded.