diff --git a/src/workerd/api/worker-rpc.c++ b/src/workerd/api/worker-rpc.c++ index 77514ea1899..510a0c32ffc 100644 --- a/src/workerd/api/worker-rpc.c++ +++ b/src/workerd/api/worker-rpc.c++ @@ -1059,7 +1059,7 @@ public: }))); if (ctx.hasOutputGate()) { - return result.then([this]() { + return result.then([weakIoContext = weakIoContext->addRef()]() mutable { return KJ_REQUIRE_NONNULL(weakIoContext->tryGet()).waitForOutputLocks(); }); } else {