From cb06a73b782c2252dd462125781c146fb1e8b8ec Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Sat, 8 Aug 2026 23:15:29 -0400 Subject: [PATCH] fix(lambda): disable HTTP/2 cleartext on the runtime API server (#2181) RuntimeApiServerTest.extensionRegister_racedAgainstStop_eventuallyDeliversShutdown flaked intermittently with an EOFException from the JDK HTTP/2 client, surviving #2156's fix for the write-vs-close ordering bug. stop() already waits for each parked write's flush to complete before closing the httpServer, but that only confirms the bytes were locally flushed, not that the peer received them before the connection is torn down - multiplexed HTTP/2 stream-completion bookkeeping on the same connection can still race that close. Real AWS's Runtime/Extensions API is plain HTTP/1.1; nothing here needs HTTP/2. Disabling h2c removes the class of multiplexed-connection races entirely and the JDK HttpClient falls back to HTTP/1.1 automatically, no client-side change required. Fixes #2180. --- .../services/lambda/runtime/RuntimeApiServer.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/lambda/runtime/RuntimeApiServer.java b/src/main/java/io/github/hectorvent/floci/services/lambda/runtime/RuntimeApiServer.java index 2ee9cc23aa..49b4aa33e4 100644 --- a/src/main/java/io/github/hectorvent/floci/services/lambda/runtime/RuntimeApiServer.java +++ b/src/main/java/io/github/hectorvent/floci/services/lambda/runtime/RuntimeApiServer.java @@ -451,7 +451,18 @@ public class RuntimeApiServer { private void tryListen(CompletableFuture started, Router router, long deadline) { if (started.isDone()) return; httpServer = vertx.createHttpServer(new HttpServerOptions() - .setMaxFormAttributeSize(-1)); + .setMaxFormAttributeSize(-1) + // Real AWS's Runtime/Extensions API is plain HTTP/1.1. Vert.x defaults to + // accepting an h2c upgrade, which the JDK HttpClient used in tests and by some + // language runtimes opts into unless told otherwise. That multiplexes every + // request from one client (e.g. an extension's register + its own /event/next + // long-poll) onto a single connection/stream-set, so stop()'s close of that + // connection can race a just-flushed response's HTTP/2 stream-completion + // bookkeeping instead of tearing down an already-idle connection — see #2180. + // Disabling h2c makes the client fall back to a plain HTTP/1.1 request + // automatically (no client-side change needed) and matches AWS's actual wire + // protocol. + .setHttp2ClearTextEnabled(false)); httpServer.requestHandler(router).listen(port, "0.0.0.0", result -> { if (result.succeeded()) { LOG.infov("RuntimeApiServer started on port {0}", String.valueOf(port));