@@ -65,9 +65,10 @@ class ContextifyContext {
65
65
explicit ContextifyContext (Environment* env, Local<Object> sandbox)
66
66
: env_(env),
67
67
sandbox_(env->isolate (), sandbox),
68
- context_(env->isolate (), CreateV8Context(env)),
69
68
// Wait for sandbox_, proxy_global_, and context_ to die
70
69
references_(0 ) {
70
+ context_.Reset (env->isolate (), CreateV8Context (env));
71
+
71
72
sandbox_.SetWeak (this , WeakCallback<Object, kSandbox >);
72
73
sandbox_.MarkIndependent ();
73
74
references_++;
@@ -361,6 +362,10 @@ class ContextifyContext {
361
362
ContextifyContext* ctx =
362
363
Unwrap<ContextifyContext>(args.Data ().As <Object>());
363
364
365
+ // Stil initializing
366
+ if (ctx->context_ .IsEmpty ())
367
+ return ;
368
+
364
369
Local<Object> sandbox = PersistentToLocal (isolate, ctx->sandbox_ );
365
370
MaybeLocal<Value> maybe_rv =
366
371
sandbox->GetRealNamedProperty (ctx->context (), property);
@@ -389,6 +394,10 @@ class ContextifyContext {
389
394
ContextifyContext* ctx =
390
395
Unwrap<ContextifyContext>(args.Data ().As <Object>());
391
396
397
+ // Stil initializing
398
+ if (ctx->context_ .IsEmpty ())
399
+ return ;
400
+
392
401
PersistentToLocal (isolate, ctx->sandbox_ )->Set (property, value);
393
402
}
394
403
@@ -401,6 +410,10 @@ class ContextifyContext {
401
410
ContextifyContext* ctx =
402
411
Unwrap<ContextifyContext>(args.Data ().As <Object>());
403
412
413
+ // Stil initializing
414
+ if (ctx->context_ .IsEmpty ())
415
+ return ;
416
+
404
417
Local<Object> sandbox = PersistentToLocal (isolate, ctx->sandbox_ );
405
418
Maybe<PropertyAttribute> maybe_prop_attr =
406
419
sandbox->GetRealNamedPropertyAttributes (ctx->context (), property);
@@ -428,6 +441,11 @@ class ContextifyContext {
428
441
429
442
ContextifyContext* ctx =
430
443
Unwrap<ContextifyContext>(args.Data ().As <Object>());
444
+
445
+ // Stil initializing
446
+ if (ctx->context_ .IsEmpty ())
447
+ return ;
448
+
431
449
Local<Object> sandbox = PersistentToLocal (isolate, ctx->sandbox_ );
432
450
433
451
Maybe<bool > success = sandbox->Delete (ctx->context (), property);
@@ -442,6 +460,10 @@ class ContextifyContext {
442
460
ContextifyContext* ctx =
443
461
Unwrap<ContextifyContext>(args.Data ().As <Object>());
444
462
463
+ // Stil initializing
464
+ if (ctx->context_ .IsEmpty ())
465
+ return ;
466
+
445
467
Local<Object> sandbox = PersistentToLocal (args.GetIsolate (), ctx->sandbox_ );
446
468
args.GetReturnValue ().Set (sandbox->GetPropertyNames ());
447
469
}
0 commit comments