@@ -103,12 +103,36 @@ export { McpExecutionOwnerDirectoryDO } from "@executor-js/cloudflare/mcp/execut
103103// until the in-flight export resolves.
104104// ---------------------------------------------------------------------------
105105
106- const fetchHandler = handler . fetch as (
106+ const rawFetchHandler = handler . fetch as (
107107 request : Request ,
108108 env : Env ,
109109 ctx : ExecutionContext ,
110110) => Response | Promise < Response > ;
111111
112+ // TEMPORARY: does an isolate that already warmed still pay for Start?
113+ let startEverHandled = false ;
114+ const fetchHandler = async (
115+ request : Request ,
116+ env : Env ,
117+ ctx : ExecutionContext ,
118+ ) : Promise < Response > => {
119+ const wasWarm = startEverHandled ;
120+ startEverHandled = true ;
121+ await scheduler . wait ( 0 ) ;
122+ const startedAt = Date . now ( ) ;
123+ const response = await rawFetchHandler ( request , env , ctx ) ;
124+ await scheduler . wait ( 0 ) ;
125+ console . log (
126+ JSON . stringify ( {
127+ probe : "start" ,
128+ path : new URL ( request . url ) . pathname ,
129+ wasWarm,
130+ ms : Date . now ( ) - startedAt ,
131+ } ) ,
132+ ) ;
133+ return response ;
134+ } ;
135+
112136const tracer = trace . getTracer ( "executor-cloud-worker" ) ;
113137
114138const traceparentValueFor = ( spanContext : SpanContext ) : string =>
@@ -220,16 +244,26 @@ const warmStartGraph = (env: Env, ctx: ExecutionContext): void => {
220244
221245 ctx . waitUntil (
222246 ( async ( ) => {
247+ const startedAt = Date . now ( ) ;
223248 // oxlint-disable-next-line executor/no-try-catch-or-throw -- adapter boundary; a warmup failure must never affect the request that triggered it
224249 try {
225250 await fetchHandler (
226251 new Request ( "https://executor.sh/robots.txt" , { method : "GET" } ) ,
227252 env ,
228253 ctx ,
229254 ) ;
230- } catch {
255+ console . log ( JSON . stringify ( { probe : "warm" , ok : true , ms : Date . now ( ) - startedAt } ) ) ;
256+ } catch ( err ) {
231257 // Advisory only — the request path still loads the graph lazily.
232258 startGraphWarmupStarted = false ;
259+ console . log (
260+ JSON . stringify ( {
261+ probe : "warm" ,
262+ ok : false ,
263+ ms : Date . now ( ) - startedAt ,
264+ err : String ( err ) ,
265+ } ) ,
266+ ) ;
233267 }
234268 } ) ( ) ,
235269 ) ;
0 commit comments