-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v18.x backport] fs: fix nonNativeWatcher leak of StatWatchers #46031
Conversation
|
||
const watcher = fs.watch(testDirectory, { recursive: true }); | ||
let watcherClosed = false; | ||
watcher.on('change', common.mustCallAtLeast(function(event, filename) { |
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.
watcher.on('change', common.mustCallAtLeast(function(event, filename) { | |
watcher.on('change', common.mustCallAtLeast((event, filename) => { |
const watcher = fs.watch(testDirectory, { recursive: true }); | ||
let watcherClosed = false; | ||
watcher.on('change', common.mustCallAtLeast(function(event, filename) { | ||
// Libuv inconsistenly emits a rename event for the file we are watching |
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.
// Libuv inconsistenly emits a rename event for the file we are watching | |
// Libuv inconsistently emits a rename event for the file we are watching |
await setTimeout(common.platformTimeout(100)); | ||
fs.writeFileSync(testFile, 'hello'); | ||
|
||
process.once('exit', function() { |
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.
process.once('exit', function() { | |
process.once('exit', () => { |
assert(!process._getActiveHandles().some((handle) => handle.constructor.name === 'StatWatcher')); | ||
})); | ||
|
||
process.on('exit', function() { |
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.
process.on('exit', function() { | |
process.on('exit', () => { |
await setTimeout(common.platformTimeout(100)); | ||
fs.writeFileSync(testFile, 'hello'); | ||
|
||
process.once('exit', function() { |
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.
We should also probably move this up a bit so that the handler is added before we start doing anything else like waiting for timers or writing to files.
@mscdex this is a backport PR, changing existing tests code will make further backporting harder since it will introduce even more conflict |
@MoLow it is recommended to specify in the PR title that it is a backport so it's easier to spot and review accordingly. |
2098d7a
to
bac6b7d
Compare
PR-URL: nodejs#45501 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
PR-URL: nodejs#45500 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
4493971
to
551a92d
Compare
This comment was marked as outdated.
This comment was marked as outdated.
7351221
to
fcfde34
Compare
backport of
#45500
#45501