diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index d4214ed7c3..779587fe36 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -888,7 +888,10 @@ void TLSWrap::Initialize(Local target, env->SetMethod(target, "wrap", TLSWrap::Wrap); - Local t = FunctionTemplate::New(env->isolate()); + auto constructor = [](const FunctionCallbackInfo& args) { + args.This()->SetAlignedPointerInInternalField(0, nullptr); + }; + auto t = env->NewFunctionTemplate(constructor); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TLSWrap")); diff --git a/test/parallel/test-tls-wrap-no-abort.js b/test/parallel/test-tls-wrap-no-abort.js new file mode 100644 index 0000000000..a64aea0b05 --- /dev/null +++ b/test/parallel/test-tls-wrap-no-abort.js @@ -0,0 +1,8 @@ +'use strict'; + +require('../common'); +const util = require('util'); +const TLSWrap = process.binding('tls_wrap').TLSWrap; + +// This will abort if internal pointer is not set to nullptr. +util.inspect(new TLSWrap());