-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
dfc2f3a
to
3ef78c4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58959 +/- ##
==========================================
- Coverage 90.09% 90.02% -0.07%
==========================================
Files 640 648 +8
Lines 188471 190963 +2492
Branches 36973 37433 +460
==========================================
+ Hits 169802 171919 +2117
- Misses 11382 11670 +288
- Partials 7287 7374 +87
🚀 New features to boost your workflow:
|
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
3ef78c4
to
b956356
Compare
Fixes: nodejs#58857 Signed-off-by: Juan José Arboleda <[email protected]>
Signed-off-by: Juan José Arboleda <[email protected]>
b956356
to
0055948
Compare
@addaleax @jasnell @Renegade334 PTAL :-) |
if (WriteSnapshot(env, final_filename.c_str(), options).IsNothing()) return; | ||
|
||
args.GetReturnValue().Set( | ||
String::NewFromUtf8(isolate, final_filename.c_str()).ToLocalChecked()); |
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.
Unfortunately this is going to be a problem because it assumes the final_filename
is utf8 encoded. Consider the following case:
const path = Buffer.from([0xe6]); // latin 1 character
fs.mkdirSync(path);
const res = v8.writeHeapSnapshot(undefined, { path });
fs.readfileSync(res); // fails! path doesn't exist
The reason fs.readfileSync
would fail here is because the returned res
will have interpreted the 0xe6
character incorrectly and will have replaced it with the unicode replacement char. The snapshot will have been written to disk correctly, but the returned path is wrong.
This likely needs to return the resulting path as a Buffer
if the path
was given as a Buffer
and allow the API to accept an encoding
option that optionally decodes the result as a string. But, that gets a bit awkward.
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.
I love how picky this is, aaah, let me put the encoding option to make this a bit more consistent and leave utf8 as default encoding.
Nice catch, thanks! Anything else missing?
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.
Nothing that sticks out, but I should have time to take another pass through by end of day monday
I'm a bit rusty with my C++. Any feedback will be more than valuable.