Skip to content

Commit 5554be3

Browse files
committed
src: split property helpers from node::Environment
nodejs/node#44056
1 parent 360bb0f commit 5554be3

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

patches/node/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ fix_expose_the_built-in_electron_module_via_the_esm_loader.patch
4747
api_pass_oomdetails_to_oomerrorcallback.patch
4848
src_iwyu_in_cleanup_queue_cc.patch
4949
fix_expose_lookupandcompile_with_parameters.patch
50+
fix_prevent_changing_functiontemplateinfo_after_publish.patch
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Shelley Vohr <shelley.vohr@gmail.com>
3+
Date: Sun, 23 Oct 2022 23:36:19 +0200
4+
Subject: fix: prevent changing FunctionTemplateInfo after publish
5+
6+
Refs https://chromium-review.googlesource.com/c/v8/v8/+/2718147
7+
8+
Fixes an issue where Node.js would try to call SetClassName on a
9+
FunctionTemplate twice in some cases. The above CL made it so that
10+
V8 CHECKs when this occurs. It is fixed by ensuring SetClassName
11+
is only called once.
12+
13+
This should be upstreamed.
14+
15+
diff --git a/src/histogram.cc b/src/histogram.cc
16+
index 3a3228ddc9eb6b53efc0721466479a9f62cd8967..175a67840348ca507d6e8b29835e5ab3b6d3e71a 100644
17+
--- a/src/histogram.cc
18+
+++ b/src/histogram.cc
19+
@@ -340,8 +340,9 @@ void HistogramBase::RegisterExternalReferences(
20+
}
21+
22+
void HistogramBase::Initialize(Environment* env, Local<Object> target) {
23+
- SetConstructorFunction(
24+
- env->context(), target, "Histogram", GetConstructorTemplate(env));
25+
+ SetConstructorFunction(env->context(), target, "Histogram",
26+
+ GetConstructorTemplate(env),
27+
+ SetConstructorFunctionFlag::NONE);
28+
}
29+
30+
BaseObjectPtr<BaseObject> HistogramBase::HistogramTransferData::Deserialize(
31+
@@ -367,6 +368,7 @@ Local<FunctionTemplate> IntervalHistogram::GetConstructorTemplate(
32+
Isolate* isolate = env->isolate();
33+
tmpl = NewFunctionTemplate(isolate, nullptr);
34+
tmpl->Inherit(HandleWrap::GetConstructorTemplate(env));
35+
+ tmpl->SetClassName(OneByteString(isolate, "Histogram"));
36+
tmpl->InstanceTemplate()->SetInternalFieldCount(
37+
HistogramBase::kInternalFieldCount);
38+
SetProtoMethodNoSideEffect(isolate, tmpl, "count", GetCount);
39+
diff --git a/src/node_messaging.cc b/src/node_messaging.cc
40+
index f88270fc75de91610a973c0649e1bc699c3e014d..e47f7a597a6ca0cfd71fec1e42f0fbb75cb539c7 100644
41+
--- a/src/node_messaging.cc
42+
+++ b/src/node_messaging.cc
43+
@@ -1467,13 +1467,16 @@ static void InitMessaging(Local<Object> target,
44+
t->Inherit(BaseObject::GetConstructorTemplate(env));
45+
t->InstanceTemplate()->SetInternalFieldCount(
46+
JSTransferable::kInternalFieldCount);
47+
- SetConstructorFunction(context, target, "JSTransferable", t);
48+
+ t->SetClassName(OneByteString(isolate, "JSTransferable"));
49+
+ SetConstructorFunction(context, target, "JSTransferable", t,
50+
+ SetConstructorFunctionFlag::NONE);
51+
}
52+
53+
SetConstructorFunction(context,
54+
target,
55+
env->message_port_constructor_string(),
56+
- GetMessagePortConstructorTemplate(env));
57+
+ GetMessagePortConstructorTemplate(env),
58+
+ SetConstructorFunctionFlag::NONE);
59+
60+
// These are not methods on the MessagePort prototype, because
61+
// the browser equivalents do not provide them.

0 commit comments

Comments
 (0)