diff --git a/src/node_errors.cc b/src/node_errors.cc index 9c4ebbe4502698..758b7631f906bc 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -616,8 +616,18 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( bool is_code_like) { HandleScope scope(context->GetIsolate()); + if (context->GetNumberOfEmbedderDataFields() <= + ContextEmbedderIndex::kAllowCodeGenerationFromStrings) { + // The context is not (yet) configured by Node.js for this. We don't + // have enough information to make a decision, just allow it which is + // the default. + return {true, {}}; + } Environment* env = Environment::GetCurrent(context); - if (env->source_maps_enabled()) { + if (env == nullptr) { + return {true, {}}; + } + if (env->source_maps_enabled() && env->can_call_into_js()) { // We do not expect the maybe_cache_generated_source_map to throw any more // exceptions. If it does, just ignore it. errors::TryCatchScope try_catch(env);