GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: deprecate exists() and existsSync() by cjihrig · Pull Request #166 · nodejs/node

Conversation

@cjihrig

@cjihrig cjihrig commented Dec 15, 2014

Copy link
Copy Markdown
Contributor

These methods don't follow standard conventions, and shouldn't be used anyway.

This closes #103

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bnoordhuis
bnoordhuis reviewed Dec 15, 2014
View reviewed changes
Comment thread lib/fs.js Outdated

@bnoordhuis bnoordhuis Dec 15, 2014

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other modules write it as module.function() and point the user to what to use instead (e.g. 'http.createClient is deprecated. Use http.request instead.'). I would suggest following that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bnoordhuis

bnoordhuis commented Dec 15, 2014

Copy link
Copy Markdown
Member

It's probably a good idea to update most uses of fs.exists() in the test suit as well. The only exceptions I can think of are simple/test-fs-exists and maybe simple/test-fs-null-bytes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig
fs: deprecate exists() and existsSync()
b94cb26
These methods don't follow standard conventions, and shouldn't
be used anyway.
@cjihrig

cjihrig commented Dec 18, 2014

Copy link
Copy Markdown
Contributor Author

@bnoordhuis ready for review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vtambourine

vtambourine commented Dec 18, 2014

Copy link
Copy Markdown

Actually, accessSync looks misconventional as well. Only way to use this method is to wrap your code with try / catch block and catch error if provided path is not accessible. The possibility to store existence in variable might be expectable.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Dec 18, 2014

Copy link
Copy Markdown
Member

@cjihrig LGTM

@vtambourine I kind of like it. I hope it discourages the anti-pattern of checking if a file exists before trying to open it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vtambourine

vtambourine commented Dec 18, 2014

Copy link
Copy Markdown

@bnoordhuis,

Can you please explain why this is considered as anti-pattern?

Besides, consider following situation. I want to ensure that set of particular files exists (set of configs, for example, server.config.js, client.config.js etc.). One way of doing that is to store the existence of each file in hash, then filter out all existing files and initialise rests with some default content. Does this solution uses anti-pattern?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Dec 18, 2014

Copy link
Copy Markdown
Member

Can you please explain why this is considered as anti-pattern?

Because the way most people use it, it's a TOCTOU race condition: the file may have changed or have been deleted between checking and opening it. If you are going to open it, then you need to be prepared for such eventualities, so you might as well skip the check and open it straight away.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vtambourine

vtambourine commented Dec 18, 2014

Copy link
Copy Markdown

Ok, thank you.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig added a commit that referenced this pull request Dec 19, 2014
@cjihrig
fs: deprecate exists() and existsSync()
5678595
These methods don't follow standard conventions, and shouldn't
be used anyway.

Fixes: #103
PR-URL: #166
Reviewed-By: Ben Noordhuis <[email protected]>
@cjihrig

cjihrig commented Dec 19, 2014

Copy link
Copy Markdown
Contributor Author

Landed in 5678595

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig cjihrig closed this Dec 19, 2014
@cjihrig
cjihrig deleted the deprecate-exists branch December 19, 2014 15:35
@cjihrig cjihrig mentioned this pull request Jan 12, 2015
sys: Mark as deprecated #309
Closed
boingoing pushed a commit to boingoing/node that referenced this pull request Apr 6, 2017
@jasongin
Rename addons_abi to addons_napi (nodejs#166)
7b49c89
This was referenced Jul 20, 2020
[Snyk] Security upgrade libnpx from 9.7.1 to 10.2.4 saurabharch/node#8
Open
[Snyk] Security upgrade libnpx from 9.7.1 to 10.2.4 KamilPolivka/node#7
Open
[Snyk] Security upgrade libnpx from 9.2.3 to 10.2.4 erdun/node#24
Open
[Snyk] Security upgrade libnpx from 9.2.3 to 10.2.4 pmq20/node#24
Open
[Snyk] Security upgrade libnpx from 9.6.0 to 10.2.4 saeedahassan/node#21
Open
[Snyk] Security upgrade libnpx from 9.6.0 to 10.2.4 olegnn/node#22
Open
@snyk-bot snyk-bot mentioned this pull request Aug 2, 2020
[Snyk] Security upgrade is-my-json-valid from 2.16.0 to 2.20.3 mkg20001/node#23
Open
This was referenced Dec 1, 2020
[Snyk] Security upgrade libnpx from 9.7.1 to 10.2.4 saurabharch/node#12
Open
[Snyk] Security upgrade libnpx from 9.7.1 to 10.2.4 KamilPolivka/node#11
Open
[Snyk] Fix for 1 vulnerabilities erdun/node#29
Open
[Snyk] Fix for 1 vulnerabilities saeedahassan/node#24
Open
[Snyk] Fix for 1 vulnerabilities olegnn/node#25
Open
This was referenced May 26, 2021
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.2 to 2.2.0 olegnn/node#29
Open
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.0-beta.7 to 2.2.0 erdun/node#34
Open
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.2 to 2.2.0 saeedahassan/node#28
Open
@bujinin bujinin mentioned this pull request Oct 4, 2021
npm not working behind a proxy in docker (16.7+) nodejs/help#3561
Closed
@KamilPolivka KamilPolivka mentioned this pull request May 13, 2022
[Snyk] Fix for 1 vulnerabilities KamilPolivka/node#25
Open
@saeedahassan saeedahassan mentioned this pull request May 13, 2022
[Snyk] Fix for 1 vulnerabilities saeedahassan/node#39
Open
@saurabharch saurabharch mentioned this pull request May 14, 2022
[Snyk] Fix for 1 vulnerabilities saurabharch/node#26
Open
@erdun erdun mentioned this pull request May 14, 2022
[Snyk] Fix for 1 vulnerabilities erdun/node#46
Open
@snyk-bot snyk-bot mentioned this pull request May 14, 2022
[Snyk] Fix for 1 vulnerabilities olegnn/node#39
Open
@verdinjoshua1982 verdinjoshua1982 mentioned this pull request Oct 14, 2022
[Snyk] Upgrade make-fetch-happen from 9.1.0 to 10.2.1 verdinjoshua1982/node#2
Open
@mStirner mStirner mentioned this pull request Jun 6, 2023
Error [ERR_INTERNAL_ASSERTION] #48358
Closed
@nickfnblum nickfnblum mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities nickfnblum/node#12
Open
This was referenced Nov 30, 2023
[Snyk] Security upgrade make-fetch-happen from 9.1.0 to 11.0.0 dannybrown13/node#50
Open
[Snyk] Fix for 1 vulnerabilities dannybrown13/node#53
Open
@ryan-ally ryan-ally mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities ryan-ally/node#90
Open
@BryanLaura BryanLaura mentioned this pull request Nov 30, 2023
[Snyk] Security upgrade make-fetch-happen from 9.1.0 to 11.0.0 BryanLaura/node#52
Open
@baby636 baby636 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities baby636/node#113
Open
@pratapadi pratapadi mentioned this pull request Nov 30, 2023
[Snyk] Security upgrade make-fetch-happen from 9.1.0 to 11.0.0 pratapadi/node#82
Open
@dewaynesmith3711 dewaynesmith3711 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities dewaynesmith3711/node#49
Open
@xphillyx xphillyx mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities xphillyx/node#27
Open
@terrorizer1980 terrorizer1980 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 3 vulnerabilities terrorizer1980/node-1#15
Open
@kaocher82 kaocher82 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Xtuden-com/node#39
Open
@terrorizer1980 terrorizer1980 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Exhorder6/node#24
Open
@snyk-io snyk-io Bot mentioned this pull request Oct 21, 2024
[Snyk] Fix for 26 vulnerabilities Graybar-codespace/node#49
Open
@coderabbitai coderabbitai Bot mentioned this pull request Aug 16, 2026
feat(commands): surface the background-subagents policy Gentleman-Programming/gentle-shell#346
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@cjihrig @bnoordhuis @vtambourine
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.