Skip to content

Commit bb8d293

Browse files
isheludkonodejs-github-bot
authored andcommitted
src: do not use soon-to-be-deprecated V8 API
V8 announced deprecation of the following methods: - v8::Object::SetAccessor(...) in favor of v8::Object::SetNativeDataProperty(...), - v8::ObjectTemplate::SetNativeDataProperty(...) with AccessControl parameter in favor of v8::ObjectTemplate::SetNativeDataProperty(...) without AccessControl parameter. See https://crrev.com/c/5006387. This slightly changes behavior of the following properties: - process.debugPort (for worker processes), - process.title (for worker processes), - process.ppid. The difference is that they will now behave like a regular writable JavaScript data properties - in case setter callback is not provided they will be be reconfigured from a native data property (the one that calls C++ callbacks upon get/set operations) to a real data property (so subsequent reads will no longer trigger C++ getter callbacks). PR-URL: #53174 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0a3f930 commit bb8d293

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

src/node_process_object.cc

+18-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace node {
1515
using v8::Context;
16-
using v8::DEFAULT;
1716
using v8::EscapableHandleScope;
1817
using v8::Function;
1918
using v8::FunctionCallbackInfo;
@@ -183,13 +182,12 @@ void PatchProcessObject(const FunctionCallbackInfo<Value>& args) {
183182

184183
// process.title
185184
CHECK(process
186-
->SetAccessor(
185+
->SetNativeDataProperty(
187186
context,
188187
FIXED_ONE_BYTE_STRING(isolate, "title"),
189188
ProcessTitleGetter,
190189
env->owns_process_state() ? ProcessTitleSetter : nullptr,
191190
Local<Value>(),
192-
DEFAULT,
193191
None,
194192
SideEffectType::kHasNoSideEffect)
195193
.FromJust());
@@ -208,9 +206,15 @@ void PatchProcessObject(const FunctionCallbackInfo<Value>& args) {
208206
READONLY_PROPERTY(process, "pid",
209207
Integer::New(isolate, uv_os_getpid()));
210208

211-
CHECK(process->SetAccessor(context,
212-
FIXED_ONE_BYTE_STRING(isolate, "ppid"),
213-
GetParentProcessId).FromJust());
209+
CHECK(process
210+
->SetNativeDataProperty(context,
211+
FIXED_ONE_BYTE_STRING(isolate, "ppid"),
212+
GetParentProcessId,
213+
nullptr,
214+
Local<Value>(),
215+
None,
216+
SideEffectType::kHasNoSideEffect)
217+
.FromJust());
214218

215219
// --security-revert flags
216220
#define V(code, _, __) \
@@ -235,11 +239,14 @@ void PatchProcessObject(const FunctionCallbackInfo<Value>& args) {
235239

236240
// process.debugPort
237241
CHECK(process
238-
->SetAccessor(context,
239-
FIXED_ONE_BYTE_STRING(isolate, "debugPort"),
240-
DebugPortGetter,
241-
env->owns_process_state() ? DebugPortSetter : nullptr,
242-
Local<Value>())
242+
->SetNativeDataProperty(
243+
context,
244+
FIXED_ONE_BYTE_STRING(isolate, "debugPort"),
245+
DebugPortGetter,
246+
env->owns_process_state() ? DebugPortSetter : nullptr,
247+
Local<Value>(),
248+
None,
249+
SideEffectType::kHasNoSideEffect)
243250
.FromJust());
244251
}
245252

test/parallel/test-worker-unsupported-things.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ if (!process.env.HAS_STARTED_WORKER) {
1414
} else {
1515
{
1616
const before = process.title;
17-
process.title += ' in worker';
18-
assert.strictEqual(process.title, before);
17+
const after = before + ' in worker';
18+
process.title = after;
19+
assert.strictEqual(process.title, after);
1920
}
2021

2122
{
2223
const before = process.debugPort;
23-
process.debugPort++;
24-
assert.strictEqual(process.debugPort, before);
24+
const after = before + 1;
25+
process.debugPort = after;
26+
assert.strictEqual(process.debugPort, after);
2527
}
2628

2729
{

0 commit comments

Comments
 (0)