Skip to content
Browse files

v8: warn in Template::Set() on improper use

The next major release will make it a fatal error to use non-primitive
values in function templates and object templates.

Print a warning that includes the C and JS stack trace to tell people to
upgrade their add-ons.  The C stack trace is only printed on platforms
that support it (the BSDs, OS X and Linux+glibc.)

The warning can be disabled with the new `--nowarn_template_set` flag.

Refs: #6216
PR-URL: #6277
Reviewed-By: James M Snell <>
  • Loading branch information...
bnoordhuis committed Apr 19, 2016
1 parent e84c693 commit 7940ecfa0093d1cc5b793f59a5c48b5050211d6b
Showing with 14 additions and 0 deletions.
  1. +11 −0 deps/v8/src/
  2. +3 −0 deps/v8/src/flag-definitions.h
@@ -939,6 +939,17 @@ void Template::Set(v8::Local<Name> name, v8::Local<Data> value,
i::Isolate* isolate = templ->GetIsolate(); i::Isolate* isolate = templ->GetIsolate();
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
auto value_obj = Utils::OpenHandle(*value);
if (i::FLAG_warn_template_set &&
value_obj->IsJSReceiver() &&
!value_obj->IsTemplateInfo()) {
"(node) v8::%sTemplate::Set() with non-primitive values is deprecated\n"
"(node) and will stop working in the next major release.\n",
templ->IsFunctionTemplateInfo() ? "Function" : "Object");
isolate->PrintStack(stderr, i::Isolate::kPrintStackConcise);
// TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo. // TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo.
i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name),
Utils::OpenHandle(*value), Utils::OpenHandle(*value),
@@ -172,6 +172,9 @@ struct MaybeBoolFlag {
// //

DEFINE_BOOL(warn_template_set, true,
"warn on deprecated v8::Template::Set() use")

DEFINE_BOOL(experimental_extras, false, DEFINE_BOOL(experimental_extras, false,
"enable code compiled in via v8_experimental_extra_library_files") "enable code compiled in via v8_experimental_extra_library_files")

0 comments on commit 7940ecf

Please sign in to comment.
You can’t perform that action at this time.