11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// Verify that AbortSignal integration works for fs.watch 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst common = require('../common'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciif (common.isIBMi) 91cb0ef41Sopenharmony_ci common.skip('IBMi does not support `fs.watch()`'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst fs = require('fs'); 121cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci{ 161cb0ef41Sopenharmony_ci // Signal aborted after creating the watcher 171cb0ef41Sopenharmony_ci const file = fixtures.path('empty.js'); 181cb0ef41Sopenharmony_ci const ac = new AbortController(); 191cb0ef41Sopenharmony_ci const { signal } = ac; 201cb0ef41Sopenharmony_ci const watcher = fs.watch(file, { signal }); 211cb0ef41Sopenharmony_ci watcher.once('close', common.mustCall()); 221cb0ef41Sopenharmony_ci setImmediate(() => ac.abort()); 231cb0ef41Sopenharmony_ci} 241cb0ef41Sopenharmony_ci{ 251cb0ef41Sopenharmony_ci // Signal aborted before creating the watcher 261cb0ef41Sopenharmony_ci const file = fixtures.path('empty.js'); 271cb0ef41Sopenharmony_ci const signal = AbortSignal.abort(); 281cb0ef41Sopenharmony_ci const watcher = fs.watch(file, { signal }); 291cb0ef41Sopenharmony_ci watcher.once('close', common.mustCall()); 301cb0ef41Sopenharmony_ci} 31