-
-
Notifications
You must be signed in to change notification settings - Fork 32k
src,lib: support path in v8.writeHeapSnapshot
output
#58959
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
base: main
Are you sure you want to change the base?
Conversation
v8.writeHeapSnapshot
output
Fixes: nodejs#58857 Signed-off-by: Juan José Arboleda <[email protected]>
Signed-off-by: Juan José Arboleda <[email protected]>
dfc2f3a
to
3ef78c4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
permission::PermissionScope::kFileSystemWrite, | ||
path.ToStringView()); | ||
|
||
final_filename = std::string(*path) + "/" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final_filename = std::string(*path) + "/" + | |
final_filename = path.ToString() + "/" + |
THROW_IF_INSUFFICIENT_PERMISSIONS( | ||
env, | ||
permission::PermissionScope::kFileSystemWrite, | ||
std::string(*path) + "/" + std::string(*filename)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string(*path) + "/" + std::string(*filename)); | |
path.ToString() + "/" + filename.ToString(); |
env, | ||
permission::PermissionScope::kFileSystemWrite, | ||
std::string(*path) + "/" + std::string(*filename)); | ||
final_filename = std::string(*path) + "/" + std::string(*filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final_filename = std::string(*path) + "/" + std::string(*filename); | |
final_filename = path.ToString() + "/" + filename.ToString(); |
But I'd encourage you to move this line up before the THROW_IF_INSUFFICIENT_PERMISSIONS
one and then just use the same variable in that
env, | ||
permission::PermissionScope::kFileSystemWrite, | ||
filename.ToStringView()); | ||
final_filename = *filename; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final_filename = *filename; | |
final_filename = filename.ToString(); |
Local<Value> filename_v = args[0]; | ||
auto options = GetHeapSnapshotOptions(args[1]); | ||
Local<String> path_v = args[2].As<String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getValidatedPath
can return a Uint8Array, so typeguarding probably needs to happen before casting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to use BufferValue
here... or, skip this and have the BufferValue
uses below just accept args[2]
. Casting as a string here is incorrect.
const filename = writeHeapSnapshot(undefined, options); | ||
// If path is set, the filename will be the provided path. | ||
if (path) assert(filename.includes(tmpdir.path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test should be expanded to cover at least cases such as:
- Passing the
path
as aBuffer
and as aURL
- Passing an unwritable path
- Passing invalid types for
path
(to test the type checking)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BufferValue
uses need to be cleaned up
I'm a bit rusty with my C++. Any feedback will be more than valuable.