@@ -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_++;
@@ -355,6 +356,10 @@ class ContextifyContext {
355
356
ContextifyContext* ctx =
356
357
Unwrap<ContextifyContext>(args.Data ().As <Object>());
357
358
359
+ // Stil initializing
360
+ if (ctx->context_ .IsEmpty ())
361
+ return ;
362
+
358
363
Local<Object> sandbox = PersistentToLocal (isolate, ctx->sandbox_ );
359
364
MaybeLocal<Value> maybe_rv =
360
365
sandbox->GetRealNamedProperty (ctx->context (), property);
@@ -383,6 +388,10 @@ class ContextifyContext {
383
388
ContextifyContext* ctx =
384
389
Unwrap<ContextifyContext>(args.Data ().As <Object>());
385
390
391
+ // Stil initializing
392
+ if (ctx->context_ .IsEmpty ())
393
+ return ;
394
+
386
395
PersistentToLocal (isolate, ctx->sandbox_ )->Set (property, value);
387
396
}
388
397
@@ -395,6 +404,10 @@ class ContextifyContext {
395
404
ContextifyContext* ctx =
396
405
Unwrap<ContextifyContext>(args.Data ().As <Object>());
397
406
407
+ // Stil initializing
408
+ if (ctx->context_ .IsEmpty ())
409
+ return ;
410
+
398
411
Local<Object> sandbox = PersistentToLocal (isolate, ctx->sandbox_ );
399
412
Maybe<PropertyAttribute> maybe_prop_attr =
400
413
sandbox->GetRealNamedPropertyAttributes (ctx->context (), property);
@@ -422,6 +435,11 @@ class ContextifyContext {
422
435
423
436
ContextifyContext* ctx =
424
437
Unwrap<ContextifyContext>(args.Data ().As <Object>());
438
+
439
+ // Stil initializing
440
+ if (ctx->context_ .IsEmpty ())
441
+ return ;
442
+
425
443
Local<Object> sandbox = PersistentToLocal (isolate, ctx->sandbox_ );
426
444
427
445
Maybe<bool > success = sandbox->Delete (ctx->context (), property);
@@ -436,6 +454,10 @@ class ContextifyContext {
436
454
ContextifyContext* ctx =
437
455
Unwrap<ContextifyContext>(args.Data ().As <Object>());
438
456
457
+ // Stil initializing
458
+ if (ctx->context_ .IsEmpty ())
459
+ return ;
460
+
439
461
Local<Object> sandbox = PersistentToLocal (args.GetIsolate (), ctx->sandbox_ );
440
462
args.GetReturnValue ().Set (sandbox->GetPropertyNames ());
441
463
}
0 commit comments