Skip to content

Commit 371adec

Browse files
committed
src: register StreamBase while registering LibuvStreamWrap
This resolves this TODO - https://github.com/nodejs/node/blob/71071f896aa9696b5d36bb3bec1c7217e7420509/src/stream_wrap.cc#L111-L112. Signed-off-by: Darshan Sen <[email protected]>
1 parent 71071f8 commit 371adec

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/stream_base.cc

+3
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ void StreamBase::AddMethods(Environment* env, Local<FunctionTemplate> t) {
452452

453453
void StreamBase::RegisterExternalReferences(
454454
ExternalReferenceRegistry* registry) {
455+
static bool is_registered = false;
456+
if (is_registered) return;
455457
registry->Register(GetFD);
456458
registry->Register(GetExternal);
457459
registry->Register(GetBytesRead);
@@ -471,6 +473,7 @@ void StreamBase::RegisterExternalReferences(
471473
registry->Register(
472474
BaseObject::InternalFieldSet<StreamBase::kOnReadFunctionField,
473475
&Value::IsFunction>);
476+
is_registered = true;
474477
}
475478

476479
void StreamBase::GetFD(const FunctionCallbackInfo<Value>& args) {

src/stream_wrap.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ void LibuvStreamWrap::RegisterExternalReferences(
108108
registry->Register(IsConstructCallCallback);
109109
registry->Register(GetWriteQueueSize);
110110
registry->Register(SetBlocking);
111-
// TODO(joyee): StreamBase::RegisterExternalReferences() is called somewhere
112-
// else but we may want to do it here too and guard it with a static flag.
111+
StreamBase::RegisterExternalReferences(registry);
113112
}
114113

115114
LibuvStreamWrap::LibuvStreamWrap(Environment* env,

0 commit comments

Comments
 (0)