Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: fs.readdir doesn't handle error correctly when the directory doesn't exist #1756

Closed
kt3k opened this issue Dec 24, 2021 · 2 comments · Fixed by #1758
Closed

node: fs.readdir doesn't handle error correctly when the directory doesn't exist #1756

kt3k opened this issue Dec 24, 2021 · 2 comments · Fixed by #1758

Comments

@kt3k
Copy link
Member

kt3k commented Dec 24, 2021

import { readdir } from "https://deno.land/[email protected]/node/fs.ts";
readdir("xyz", (err) => {
  console.log("error");
});

This script should print "error" and exit normally, but it errors with uncaught error.

@bartlomieju
Copy link
Member

The problematic code is here:
https://github.com/denoland/deno_std/blob/6bbfc8f48cfdcdcf007773d7b03c8b3a0543c658/node/_fs/_fs_watch.ts#L5-L38

Both of these helper functions only use handlers if promise resolves successfuly, neither can handle errors raised from the iterators.

@kt3k
Copy link
Member Author

kt3k commented Dec 24, 2021

Thanks for the input. I'll work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants