Should "exists" function from STD be used as a last resort?

There was an undo deprecation for "exists" functions but still in the code it says this: Note: Do not use this function if performing a check before another operation on that file. Doing so creates a race condition. Instead, perform the actual file operation directly. So basically this message and the description in the PR, would mean use it but as last resort? e.g: third party scenarios? Thanks. https://github.com/denoland/deno_std/pull/2785
GitHub
feat(fs): undo deprecation of exists and add permission and type ...
Introduces readable Undos the deprecation and enhances exists of the fs module. exists was deprecated due to TOCTOU issues, but there are valid use cases to have such function: Checking for path a...
3 Replies
AapoAlas
AapoAlas2y ago
Some valid use cases are mentioned in the pull requests. But indeed you should avoid using the function unless you really have to.
ioB
ioB2y ago
for >95% of cases where you think you need it, you don’t and you’re doing it wrong
Santiago Aguilar Hernandez
Fair enough, thank you for your responses 😁