You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The deno polyfill for node fsPromises.watch() does not appear to return an AsyncIteratoras documented here for node.
With deno run, using the returned watcher with for await throws TypeError: watcher is not async iterable.
The same code works with node.
$ deno run fswatch-node.js
✅ Granted read access to <CWD>.
Watching for file changes in /Users/jldec/opral/deno, press Ctrl+C to exit.
error: Uncaught (in promise) TypeError: watcher is not async iterable
for await (const event of watcher) {
^
at run (file:///Users/jldec/opral/deno/fswatch-node.js:8:29)
at file:///Users/jldec/opral/deno/fswatch-node.js:13:1
$ node fswatch-node.js
Watching for file changes in /Users/jldec/opral/deno-node-fs-promises-watch, press Ctrl+C to exit.
>>>> event { eventType: 'rename', filename: 'foo.bar' }
importprocessfrom"node:process"importfsfrom"node:fs/promises"asyncfunctionrun(){constwatcher=fs.watch(process.cwd(),{recursive: true})console.log(`Watching for file changes in ${process.cwd()}, press Ctrl+C to exit.`);forawait(consteventofwatcher){console.log(">>>> event",event)}}run()
Version: Deno 1.42.4
The deno polyfill for
node fsPromises.watch()
does not appear to return anAsyncIterator
as documented here for node.With deno run, using the returned watcher with
for await
throwsTypeError: watcher is not async iterable
.The same code works with node.
repro
fswatch-node.js from: https://github.com/jldec/deno-node-fs-promises-watch
Ref: https://github.com/denoland/deno/blob/main/ext/node/polyfills/_fs/_fs_watch.ts#L126C5-L126C18
The text was updated successfully, but these errors were encountered: