-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: add AbortSignal support to watch
PR-URL: #37190 Refs: #37179 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
- Loading branch information
1 parent
5906e85
commit acd087d
Showing
3 changed files
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
|
||
// Verify that AbortSignal integration works for fs.watch | ||
|
||
const common = require('../common'); | ||
|
||
if (common.isIBMi) | ||
common.skip('IBMi does not support `fs.watch()`'); | ||
|
||
const fs = require('fs'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
|
||
{ | ||
// Signal aborted after creating the watcher | ||
const file = fixtures.path('empty.js'); | ||
const ac = new AbortController(); | ||
const { signal } = ac; | ||
const watcher = fs.watch(file, { signal }); | ||
watcher.once('close', common.mustCall()); | ||
setImmediate(() => ac.abort()); | ||
} | ||
{ | ||
// Signal aborted before creating the watcher | ||
const file = fixtures.path('empty.js'); | ||
const ac = new AbortController(); | ||
const { signal } = ac; | ||
ac.abort(); | ||
const watcher = fs.watch(file, { signal }); | ||
watcher.once('close', common.mustCall()); | ||
} |