From 01d38a4e4c84d9d3d50845934816e0fc0e046224 Mon Sep 17 00:00:00 2001 From: Rhys Sullivan <39114868+RhysSullivan@users.noreply.github.com> Date: Tue, 18 Aug 2026 15:25:53 -0700 Subject: [PATCH] Clock-sync both sides of fetchHandler so handlerMs is real A handler that performs no I/O leaves Date.now() pinned, so the first run reported handlerMs 0 against 6002ms wall. Sync before and after. --- apps/cloud/src/server.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/cloud/src/server.ts b/apps/cloud/src/server.ts index ee7aba5a9..b8d4186a1 100644 --- a/apps/cloud/src/server.ts +++ b/apps/cloud/src/server.ts @@ -129,8 +129,14 @@ const fetchHandler = async ( ): Promise => { const wasWarm = startHandledInThisIsolate; startHandledInThisIsolate = true; + // Sync the clock on BOTH sides. Without the trailing `scheduler.wait(0)`, + // a handler that performs no I/O leaves `Date.now()` pinned and reports + // 0ms for work that actually took seconds — which is exactly what the + // first run of this probe showed (handlerMs 0 against 6002ms wall). + await scheduler.wait(0); const startedAt = Date.now(); const response = await rawFetchHandler(request, env, ctx); + await scheduler.wait(0); const handlerMs = Date.now() - startedAt; console.log( JSON.stringify({