forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 5
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: nodejs#37190 Refs: nodejs#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
5e69c69
commit 70f1f8d
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 --experimental-abortcontroller | ||
'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()); | ||
} |