• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --expose-internals --experimental-abortcontroller
2'use strict';
3
4// Verify that AbortSignal integration works for fs.watch
5
6const common = require('../common');
7
8if (common.isIBMi)
9  common.skip('IBMi does not support `fs.watch()`');
10
11const fs = require('fs');
12const fixtures = require('../common/fixtures');
13
14
15{
16  // Signal aborted after creating the watcher
17  const file = fixtures.path('empty.js');
18  const ac = new AbortController();
19  const { signal } = ac;
20  const watcher = fs.watch(file, { signal });
21  watcher.once('close', common.mustCall());
22  setImmediate(() => ac.abort());
23}
24{
25  // Signal aborted before creating the watcher
26  const file = fixtures.path('empty.js');
27  const ac = new AbortController();
28  const { signal } = ac;
29  ac.abort();
30  const watcher = fs.watch(file, { signal });
31  watcher.once('close', common.mustCall());
32}
33