diff --git a/WORKSPACE b/WORKSPACE index 4ee56e8ed4e..87c9806d396 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,10 +35,10 @@ rules_foreign_cc_dependencies() http_archive( name = "capnp-cpp", - sha256 = "7ccdf8eeed127d439bc8a94d5742f87d3e5e305f13c3bbb2797005eb6705bf98", - strip_prefix = "capnproto-capnproto-d0e3946/c++", + sha256 = "f2545a2de980f4de51b28ed305098964e4f4367faa8f70b0178cbc0851c407c4", + strip_prefix = "capnproto-capnproto-3e54cc2/c++", type = "tgz", - urls = ["https://github.com/capnproto/capnproto/tarball/d0e3946787b635c7196ded373ae867642e0cf5c7"], + urls = ["https://github.com/capnproto/capnproto/tarball/3e54cc22972658393cd430c5d5eac17d1c0a9fb7"], ) http_archive( diff --git a/src/workerd/api/analytics-engine.capnp b/src/workerd/api/analytics-engine.capnp index e6e53f9eca5..14628e48ffd 100644 --- a/src/workerd/api/analytics-engine.capnp +++ b/src/workerd/api/analytics-engine.capnp @@ -4,7 +4,9 @@ @0x8fe697b0d6269a23; -$import "/capnp/c++.capnp".namespace("workerd::api"); +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("workerd::api"); +$Cxx.allowCancellation; # ======================================================================================== # DO NOT MODIFY BELOW THIS COMMENT -- except if copying from the authoritative version. diff --git a/src/workerd/api/r2-api.capnp b/src/workerd/api/r2-api.capnp index 386f9116e8a..32376f88e9a 100644 --- a/src/workerd/api/r2-api.capnp +++ b/src/workerd/api/r2-api.capnp @@ -8,6 +8,7 @@ using Cxx = import "/capnp/c++.capnp"; using Json = import "/capnp/compat/json.capnp"; $Cxx.namespace("workerd::api::public_beta"); +$Cxx.allowCancellation; const versionPublicBeta :UInt32 = 1; diff --git a/src/workerd/io/actor-storage.capnp b/src/workerd/io/actor-storage.capnp index 7a4d5d0976c..dd4cae8d4e7 100644 --- a/src/workerd/io/actor-storage.capnp +++ b/src/workerd/io/actor-storage.capnp @@ -4,7 +4,9 @@ @0xb200a391b94343f1; -$import "/capnp/c++.capnp".namespace("workerd::rpc"); +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("workerd::rpc"); +$Cxx.allowCancellation; interface ActorStorage @0xd7759d7fc87c08e4 { struct KeyValue { diff --git a/src/workerd/io/cdp.capnp b/src/workerd/io/cdp.capnp index 9295f11d80c..dcd399306ed 100644 --- a/src/workerd/io/cdp.capnp +++ b/src/workerd/io/cdp.capnp @@ -10,6 +10,7 @@ using Cxx = import "/capnp/c++.capnp"; using Json = import "/capnp/compat/json.capnp"; $Cxx.namespace("workerd::cdp"); +$Cxx.allowCancellation; enum LogType { log @0; diff --git a/src/workerd/io/compatibility-date.capnp b/src/workerd/io/compatibility-date.capnp index 50434d8790d..ebb38c49170 100644 --- a/src/workerd/io/compatibility-date.capnp +++ b/src/workerd/io/compatibility-date.capnp @@ -4,7 +4,9 @@ @0x8b3d4aaa36221ec8; -$import "/capnp/c++.capnp".namespace("workerd"); +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("workerd"); +$Cxx.allowCancellation; const supportedCompatibilityDate :Text = "2022-11-08"; # Newest compatibility date that can safely be set using code compiled from this repo. Trying to diff --git a/src/workerd/io/jaeger.capnp b/src/workerd/io/jaeger.capnp index f995287c9b4..0080319a279 100644 --- a/src/workerd/io/jaeger.capnp +++ b/src/workerd/io/jaeger.capnp @@ -4,7 +4,9 @@ @0xd25a546ad8e45f46; -$import "/capnp/c++.capnp".namespace("workerd::rpc"); +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("workerd::rpc"); +$Cxx.allowCancellation; struct JaegerSpan @0x946ed67bd99d1210 { traceIdHigh @0 :UInt64; diff --git a/src/workerd/io/outcome.capnp b/src/workerd/io/outcome.capnp index 2d5a760ae32..18315e674ac 100644 --- a/src/workerd/io/outcome.capnp +++ b/src/workerd/io/outcome.capnp @@ -4,7 +4,9 @@ @0xe27bb9203d5e02a8; -$import "/capnp/c++.capnp".namespace("workerd"); +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("workerd"); +$Cxx.allowCancellation; # ======================================================================================== # DO NOT MODIFY BELOW THIS COMMENT -- except if copying from the authoritative version. diff --git a/src/workerd/io/worker-interface.capnp b/src/workerd/io/worker-interface.capnp index 372ef7c668a..f7dd37fd375 100644 --- a/src/workerd/io/worker-interface.capnp +++ b/src/workerd/io/worker-interface.capnp @@ -6,6 +6,8 @@ using Cxx = import "/capnp/c++.capnp"; $Cxx.namespace("workerd::rpc"); +# We do not use `$Cxx.allowCancellation` because runAlarm() currently depends on blocking +# cancellation. using import "/capnp/compat/http-over-capnp.capnp".HttpMethod; using import "/capnp/compat/http-over-capnp.capnp".HttpService; @@ -97,16 +99,17 @@ struct AlarmRun @0xfa8ea4e97e23b03d { interface EventDispatcher @0xf20697475ec1752d { # Interface used to deliver events to a Worker's global event handlers. - getHttpService @0 () -> (http :HttpService); + getHttpService @0 () -> (http :HttpService) $Cxx.allowCancellation; # Gets the HTTP interface to this worker (to trigger FetchEvents). - sendTraces @1 (traces :List(Trace)); + sendTraces @1 (traces :List(Trace)) $Cxx.allowCancellation; # Deliver a trace event to a trace worker. This always completes immediately; the trace handler # runs as a "waitUntil" task. - prewarm @2 (url :Text); + prewarm @2 (url :Text) $Cxx.allowCancellation; - runScheduled @3 (scheduledTime :Int64, cron :Text) -> (result :ScheduledRun); + runScheduled @3 (scheduledTime :Int64, cron :Text) -> (result :ScheduledRun) + $Cxx.allowCancellation; # Runs a scheduled worker. Returns a ScheduledRun, detailing information about the run such as # the outcome and whether the run should be retried. This does not complete immediately. @@ -116,6 +119,10 @@ interface EventDispatcher @0xf20697475ec1752d { # scheduledTime is a unix timestamp in milliseconds for when the alarm should be run # Returns an AlarmRun, detailing information about the run such as # the outcome and whether the run should be retried. This does not complete immediately. + # + # TODO(cleanup): runAlarm()'s implementation currently relies on *not* allowing cancellation. + # It would be cleaner to handle that inside the implementation so we could mark the entire + # interface (and file) with allowCancellation. obsolete5 @5(); obsolete6 @6(); diff --git a/src/workerd/jsg/rtti.capnp b/src/workerd/jsg/rtti.capnp index 033f051456a..2f9ad13e4d4 100644 --- a/src/workerd/jsg/rtti.capnp +++ b/src/workerd/jsg/rtti.capnp @@ -5,7 +5,9 @@ @0xb042d6da9e1721ad; # Runtime information about jsg types and definitions -$import "/capnp/c++.capnp".namespace("workerd::jsg::rtti"); +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("workerd::jsg::rtti"); +$Cxx.allowCancellation; struct Type { # A description of the C++ type. diff --git a/src/workerd/server/workerd.capnp b/src/workerd/server/workerd.capnp index 6dd9be80c43..f2259cce2e2 100644 --- a/src/workerd/server/workerd.capnp +++ b/src/workerd/server/workerd.capnp @@ -34,7 +34,9 @@ # afraid to fall back to code for anything the config cannot express, as Workers are very fast # to execute! -$import "/capnp/c++.capnp".namespace("workerd::server::config"); +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("workerd::server::config"); +$Cxx.allowCancellation; struct Config { # Top-level configuration for a workerd instance. diff --git a/src/workerd/util/capnp-mock.h b/src/workerd/util/capnp-mock.h index 2beec7b94cd..df227ff58b9 100644 --- a/src/workerd/util/capnp-mock.h +++ b/src/workerd/util/capnp-mock.h @@ -329,7 +329,8 @@ class MockServer: public kj::Refcounted { class Server final: public capnp::DynamicCapability::Server { public: Server(MockServer& mock) - : capnp::DynamicCapability::Server(mock.schema), mock(kj::addRef(mock)) {} + : capnp::DynamicCapability::Server(mock.schema, {.allowCancellation = true}), + mock(kj::addRef(mock)) {} ~Server() noexcept(false) { mock->dropped = true; KJ_IF_MAYBE(w, mock->waiter) { @@ -339,7 +340,6 @@ class MockServer: public kj::Refcounted { kj::Promise call(capnp::InterfaceSchema::Method method, capnp::CallContext context) override { - context.allowCancellation(); return kj::newAdaptedPromise(*mock, method, kj::mv(context)); }