Restore Node 24 (and before) behavior as fs.existsSync() now throws deprecation warning - #474
Open
kroh wants to merge 3 commits into
Open
Restore Node 24 (and before) behavior as fs.existsSync() now throws deprecation warning#474kroh wants to merge 3 commits into
kroh wants to merge 3 commits into
Conversation
…en passed invalid undefined/objects
✅ Deploy Preview for lando-core ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Member
|
Thanks for tracking this down! The Node 24 diagnosis looks right, and it should be possible to fix while retaining Node 20 compatibility. Could we avoid globally monkey-patching Node's I'd suggest a small explicit helper that returns |
Node 24 deprecated passing anything that is not a string, Buffer or URL to fs.existsSync(). Older Node quietly returned false, which a number of lando call sites relied on: they pluck optional keys off plugin and config objects and just want a "is there a file there?" answer. On Node 24 those now emit a DeprecationWarning to stderr on more or less every lando invocation. Add utils/exists-sync.js, which returns false for non path-like values and otherwise defers to fs.existsSync(). Also expose it as utils.existsSync so plugins can use it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

The problem
Execution of lando results in the following error:
What was wrong
Node 24 introduced deprecation DEP0187:
fs.existsSync()now warns when passed anything that isn't a string/Buffer/URL. Older Node silently returned false. Lando relies on that old behavior in many places — it callsfs.existsSync(x)where x is often undefined or an object (e.g. plugin dirs that don't exist, config source objects). Each command bootstraps different subsystems, so different call sites fired.The fix
Rather than guard dozens of individual call sites (fragile and incomplete), I added a single global shim at Lando's entry point at @lando/core/bin/lando:
This restores the pre-Node-24 semantics (non-path argument returns false), so behavior is unchanged, just no warning.