diff --git a/src/context.cc b/src/context.cc index 4b31f607..c1929e14 100644 --- a/src/context.cc +++ b/src/context.cc @@ -331,9 +331,24 @@ bool ContextBase::onStart(std::shared_ptr plugin) { } bool ContextBase::onConfigure(std::shared_ptr plugin) { - if (isFailed() || !wasm_->on_configure_) { + if (isFailed()) { return true; } + + // on_context_create is yet to be executed for all the root contexts except the first one + if (!in_vm_context_created_ && wasm_->on_context_create_) { + DeferAfterCallActions actions(this); + wasm_->on_context_create_(this, id_, 0); + } + + // NB: If no on_context_create function is registered the in-VM SDK is responsible for + // managing any required in-VM state. + in_vm_context_created_ = true; + + if (!wasm_->on_configure_) { + return true; + } + DeferAfterCallActions actions(this); plugin_ = plugin; auto result =