Skip to content

src: improve StringBytes error handling #57706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2025

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Apr 1, 2025

Improve error handling and the signature of StringBytes::Encode(...).

Also, mark the node::Encode(...) C++ APIs as deprecated since those do not propagate errors correctly. Added node::TryEncode(...) replacements that properly return MaybeLocal<String> and propagate errors.

@jasnell jasnell requested review from anonrig and joyeecheung April 1, 2025 13:41
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-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 Apr 1, 2025
@jasnell jasnell force-pushed the jasnell/string_bytes branch from 1fab9ca to 715f9ae Compare April 1, 2025 14:23

This comment was marked as outdated.

@jasnell jasnell requested a review from anonrig April 1, 2025 17:05
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Apr 3, 2025

@jasnell jasnell requested a review from aduh95 April 3, 2025 19:04
@jasnell jasnell added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 3, 2025
Comment on lines +188 to -196
args.GetReturnValue().Set(ret);
}

args.GetReturnValue().Set(ret);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd find it more readable to return on the error path, possibly with a comment, and keep the .Set() call on the top-level of the body of the function

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 6, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 6, 2025
@nodejs-github-bot nodejs-github-bot merged commit 93644d5 into nodejs:main Apr 6, 2025
59 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 93644d5

JonasBa pushed a commit to JonasBa/node that referenced this pull request Apr 11, 2025
PR-URL: nodejs#57706
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
RafaelGSS pushed a commit that referenced this pull request May 1, 2025
PR-URL: #57706
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
RafaelGSS pushed a commit that referenced this pull request May 2, 2025
PR-URL: #57706
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95
Copy link
Contributor

aduh95 commented May 6, 2025

Could you open a backport PR to v22.x-staging please?

@aduh95 aduh95 added the backport-requested-v22.x PRs awaiting manual backport to the v22.x-staging branch. label May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. backport-requested-v22.x PRs awaiting manual backport to the v22.x-staging branch. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants