Skip to content

Conversation

@bjohansebas
Copy link
Contributor

@bjohansebas bjohansebas commented Aug 13, 2025

Changes

After doing some more research, i found that if dirPath is not a string or buffer, it will throw an error internally (in https://github.com/nodejs/node/blob/9ec68afdc505215cd7b39c6fab35f11e3efa4fc7/lib/internal/fs/utils.js#L701). However, existsSync does not currently throw that error, it only issues a warning when that error code occurs ( https://github.com/nodejs/node/blob/9ec68afdc505215cd7b39c6fab35f11e3efa4fc7/lib/fs.js#L274).

In future versions of nodejs, if existsSync encounters that error code, it will throw an error. With this, our change should be fine.

The other uses of existsSync in Astro’s codebase already convert the path to a string using path.join or path.resolve, so this should be the only change needed to remove the warning.

closes: #14214
closes #14215

Testing

Docs

@changeset-bot
Copy link

changeset-bot bot commented Aug 13, 2025

🦋 Changeset detected

Latest commit: 04192ad

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: create-astro Related to the `create-astro` package (scope) label Aug 13, 2025
…efore checking its existence

Signed-off-by: Sebastian Beltran <[email protected]>
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

Do we know why dirPath isn’t a string here? We’re typing it as a string and presumably passing it something we think is a string, so I’m a bit surprised if it isn’t. What type were you seeing here?

i found that if dirPath is not a string or buffer, it will throw an error internally

Note that file URLs are also allowed (this is documented and you can see the conversion to string happening before they check validity).

Signed-off-by: Sebastian Beltran <[email protected]>
@bjohansebas
Copy link
Contributor Author

Basically, if the path isn’t passed as an argument in the console, projectName is undefined (

let cwd = flags['_'][0];
). What can be done is what I just pushed in 04192ad, or at add a conditional so that if it’s undefined it returns ''.

It would be better to patch isEmpty, in case it ends up being used in other places in the future.

];

export function isEmpty(dirPath: string) {
export function isEmpty(dirPath: string | undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a default parameter value would be sufficient here? ie

function isEmpty(dirPath: string = "")

'create-astro': patch
---

Ensure that isEmpty converts dirPath to a string before checking its existence, since a future version of Node.js will throw an error.
Copy link
Contributor

Choose a reason for hiding this comment

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

The changeset is user-facing, so should tell users how it affects them, rather than the implementation. So here it would be something about it preventing it from logging a warning in Node 24+

@ascorbic
Copy link
Contributor

ascorbic commented Sep 1, 2025

I think rather than changing isEmpty, the change should be in projectName. If there is no ctx.cwd passed, then it shouldn't be checking if it's empty.

@florian-lefebvre
Copy link
Member

Hi @bjohansebas, are you still interested in this PR?

@florian-lefebvre florian-lefebvre added the needs response Issue needs response from OP label Oct 6, 2025
@florian-lefebvre
Copy link
Member

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs response Issue needs response from OP pkg: create-astro Related to the `create-astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeprecationWarning when running npm create astro@latest with node v24.5.0

6 participants