Skip to content

Commit c3d38fb

Browse files
committed
fs: deprecate never throw behaviour in fs.existsSync
1 parent e0145b4 commit c3d38fb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

doc/api/deprecations.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3774,6 +3774,19 @@ Type: Runtime
37743774

37753775
The `util.getCallSite` API has been removed. Please use [`util.getCallSites()`][] instead.
37763776

3777+
### DEP0187: `fs.existsSync` never throw on invalid arguments
3778+
3779+
<!-- YAML
3780+
changes:
3781+
- version: REPLACEME
3782+
pr-url: https://github.com/nodejs/node/pull/55753
3783+
description: Runtime deprecation.
3784+
-->
3785+
3786+
Type: Runtime
3787+
3788+
Returning false on validation errors is deprecated.
3789+
37773790
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
37783791
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
37793792
[RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4

lib/fs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ const {
149149
validateString,
150150
kValidateObjectAllowNullable,
151151
} = require('internal/validators');
152+
const { deprecate } = require('internal/util');
152153

153154
const permission = require('internal/process/permission');
154155

@@ -276,7 +277,6 @@ ObjectDefineProperty(exists, kCustomPromisifiedSymbol, {
276277
// the expectation that passing invalid arguments to it, even like
277278
// fs.existsSync(), would only get a false in return, so we cannot signal
278279
// validation errors to users properly out of compatibility concerns.
279-
// TODO(joyeecheung): deprecate the never-throw-on-invalid-arguments behavior
280280
/**
281281
* Synchronously tests whether or not the given path exists.
282282
* @param {string | Buffer | URL} path
@@ -286,6 +286,7 @@ function existsSync(path) {
286286
try {
287287
path = getValidatedPath(path);
288288
} catch {
289+
util.deprecate(() => {}, 'never throw on invalid arguments for fs.existsSync is deprecated', 'DEP187');
289290
return false;
290291
}
291292

0 commit comments

Comments
 (0)