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.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-08-08 22:15:29 -05:00
1 parent 396ef55512
commit cb06a73b78
1 file changed
+12 -1
@@ -451,7 +451,18 @@ public class RuntimeApiServer {
private void tryListen(CompletableFuture<Void> 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));