mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
permission: support v8.setHeapSnapshotNearHeapLimit
Signed-off-by: ishabi <ilyasshabi94@gmail.com> PR-URL: https://github.com/nodejs/node/pull/64808 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
This commit is contained in:
1 parent
108b883d0b
commit
9f9a96030d
2 files changed
+18
No files matched your search
@@ -27,6 +27,7 @@
|
||||
#include "node.h"
|
||||
#include "node_external_reference.h"
|
||||
#include "node_profiling.h"
|
||||
#include "permission/permission.h"
|
||||
#include "util-inl.h"
|
||||
#include "v8-profiler.h"
|
||||
#include "v8.h"
|
||||
@@ -199,6 +200,14 @@ void SetHeapSnapshotNearHeapLimit(const FunctionCallbackInfo<Value>& args) {
|
||||
Environment* env = Environment::GetCurrent(args);
|
||||
uint32_t limit = args[0].As<v8::Uint32>()->Value();
|
||||
CHECK_GT(limit, 0);
|
||||
|
||||
std::string dir = env->options()->diagnostic_dir;
|
||||
if (dir.empty()) {
|
||||
dir = Environment::GetCwd(env->exec_path());
|
||||
}
|
||||
THROW_IF_INSUFFICIENT_PERMISSIONS(
|
||||
env, permission::PermissionScope::kFileSystemWrite, dir);
|
||||
|
||||
env->AddHeapSnapshotNearHeapLimitCallback();
|
||||
env->set_heap_snapshot_near_heap_limit(limit);
|
||||
}
|
||||
|
||||
@@ -34,3 +34,12 @@ const path = require('path');
|
||||
permission: 'FileSystemWrite',
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
assert.throws(() => {
|
||||
v8.setHeapSnapshotNearHeapLimit(1);
|
||||
}, common.expectsError({
|
||||
code: 'ERR_ACCESS_DENIED',
|
||||
permission: 'FileSystemWrite',
|
||||
}));
|
||||
}
|
||||
Reference in new issue
Block a user