Skip to content

Conversation

@anonrig
Copy link
Member

This is somewhat similar to #49970, with major modifications to input validation to avoid making this a breaking change due to the input validation on Infinity and NaN on the original PR. Credit to @andremralves for the initial push.

The original PR was blocked due to @tniessen's following comment:

Unless I'm missing something, some functions now don't throw synchronously anymore but instead report the validation error to the callback, which seems unusual for argument validation. I am not sure if that's desirable (or if we treat these things as semver-major).

This does not apply because we throw the error synchronously from the C++ side. A similar work was done on getValidatedFd couple of months ago. (Ref: #51027)

In promisified calls the error was thrown inside an async function, and it is thrown the similar way. For non promisified calls, right now the error is thrown still synchronously but inside the C++ file before any callback execution is done.

The only difference is the order of errors. For example, previously for a callback version of access we were checking the validity of mode and later the validity of callback, right now mode is checked later. According to the documentation, and if I'm not mistaken, this is not a breaking change.

cc @nodejs/fs @tniessen @nodejs/performance @nodejs/cpp-reviewers


And most importantly, I'm back.

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 12, 2024
@anonriganonrigforce-pushed the move-get-valid-mode-to-cpp branch from 9e327e7 to f88f1f1CompareMarch 12, 2024 01:19
Copy link
Member

@H4adH4ad left a comment

Choose a reason for hiding this comment

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

Good to have you back! Just leave some non-blocking comments.

@anonriganonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 12, 2024
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 12, 2024
@nodejs-github-bot
Copy link
Collaborator

@anonriganonrig added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 12, 2024
@RafaelGSS
Copy link
Member

RafaelGSS commented Mar 12, 2024

For example, previously for a callback version of access we were checking the validity of mode and later the validity of callback, right now mode is checked later

Honestly, I have a feeling this should be considered a semver-major. While we do not consider changing the error message to semver-major, changing the order of ERR_CODE should be considered a semver-major.

This, however, should impact only tests (error conditions). So, if everybody agrees, it shouldn't be that bad to land as a non-semver-major PR (mainly on non-LTS lines).


Also, I suspect we are only changing it for performance purposes, right? Would you be able to share benchmarks (preferably in a dedicated machine)?

@anonrig
Copy link
MemberAuthor

Honestly, I have a feeling this should be considered a semver-major. While we do not consider changing the error message to semver-major, changing the order of ERR_CODE should be considered a semver-major.

@RafaelGSS I'm -0.5 on making this a semver-major change, because of the past pull-requests. For example, similar PR was landed (#51027) without semver-major. Also, it's extremely easy to make this change since by just moving the order of any validate operation, you can easily break the order.

If we follow this path, calling this major change, we should document this before landing this pull-request. But I believe we shouldn't make a claim to preserve the order of errors since it will stall a lot of optimization opportunities by max 1 year (release of major).

Also, I suspect we are only changing it for performance purposes, right? Would you be able to share benchmarks (preferably in a dedicated machine)?

@RafaelGSS The original PR has some benchmark results. I don't have access to a dedicated machine to back this claim, but the results from original PR stands: #49970

@anonriganonrigforce-pushed the move-get-valid-mode-to-cpp branch from f88f1f1 to 211ad4dCompareMarch 12, 2024 23:34
@anonriganonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 13, 2024
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 13, 2024
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@mcollinamcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@anonriganonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 13, 2024
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 14, 2024
@nodejs-github-botnodejs-github-bot merged commit 3ec20f2 into nodejs:mainMar 14, 2024
@nodejs-github-bot
Copy link
Collaborator

Landed in 3ec20f2

rdw-msft pushed a commit to rdw-msft/node that referenced this pull request Mar 26, 2024
PR-URL: nodejs#52050 Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
PR-URL: #52050 Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
@marco-ippolitomarco-ippolito mentioned this pull request May 2, 2024
marco-ippolito pushed a commit that referenced this pull request May 3, 2024
PR-URL: #52050 Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
jcbhmr pushed a commit to jcbhmr/node that referenced this pull request May 15, 2024
PR-URL: nodejs#52050 Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.c++Issues and PRs that require attention from people who are familiar with C++.lib / srcIssues and PRs related to general changes in the lib or src directory.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@anonrig@nodejs-github-bot@RafaelGSS@mcollina@ShogunPanda@lemire@H4ad