From 8f27d1cfa7b174fb83e65065b9b49a81d8866aa4 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Fri, 12 Dec 2025 06:14:08 +1000 Subject: [PATCH] fix(executor): declare packageName/exportName before try block Same issue as startTime - these variables were destructured inside the try block but referenced in the catch block for health reporting. If JSON parsing or any early error occurred, the catch block would crash with 'packageName is not defined'. Now declares them with 'unknown' defaults before try, then assigns the actual values inside. --- apps/railway-executor/server.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/railway-executor/server.ts b/apps/railway-executor/server.ts index cb6d645..3d8e321 100644 --- a/apps/railway-executor/server.ts +++ b/apps/railway-executor/server.ts @@ -379,9 +379,14 @@ async function loadAndDescribe(req: Request): Promise { */ async function executeTool(req: Request): Promise { const startTime = Date.now(); + // Declare these before try block so they're available in catch for error reporting + let packageName = 'unknown'; + let exportName = 'unknown'; try { const body = await req.json(); - const { packageName, exportName, version, importUrl, params, env } = body; + const { packageName: pkg, exportName: exp, version, importUrl, params, env } = body; + packageName = pkg || 'unknown'; + exportName = exp || 'unknown'; console.log('📥 Execute request:', { packageName,