@@ -169,6 +169,10 @@ Maybe<bool> SerializerContext::WriteHostObject(Isolate* isolate,
169169
170170void SerializerContext::New (const FunctionCallbackInfo<Value>& args) {
171171 Environment* env = Environment::GetCurrent (args);
172+ if (!args.IsConstructCall ()) {
173+ return THROW_ERR_CONSTRUCT_CALL_REQUIRED (
174+ env, " Class constructor Serializer cannot be invoked without 'new'" );
175+ }
172176
173177 new SerializerContext (env, args.This ());
174178}
@@ -319,6 +323,10 @@ MaybeLocal<Object> DeserializerContext::ReadHostObject(Isolate* isolate) {
319323
320324void DeserializerContext::New (const FunctionCallbackInfo<Value>& args) {
321325 Environment* env = Environment::GetCurrent (args);
326+ if (!args.IsConstructCall ()) {
327+ return THROW_ERR_CONSTRUCT_CALL_REQUIRED (
328+ env, " Class constructor Deserializer cannot be invoked without 'new'" );
329+ }
322330
323331 if (!args[0 ]->IsArrayBufferView ()) {
324332 return node::THROW_ERR_INVALID_ARG_TYPE (
@@ -470,6 +478,7 @@ void Initialize(Local<Object> target,
470478 Local<String> serializerString =
471479 FIXED_ONE_BYTE_STRING (env->isolate (), " Serializer" );
472480 ser->SetClassName (serializerString);
481+ ser->ReadOnlyPrototype ();
473482 target->Set (env->context (),
474483 serializerString,
475484 ser->GetFunction (env->context ()).ToLocalChecked ()).Check ();
@@ -496,6 +505,8 @@ void Initialize(Local<Object> target,
496505
497506 Local<String> deserializerString =
498507 FIXED_ONE_BYTE_STRING (env->isolate (), " Deserializer" );
508+ des->SetLength (1 );
509+ des->ReadOnlyPrototype ();
499510 des->SetClassName (deserializerString);
500511 target->Set (env->context (),
501512 deserializerString,
0 commit comments