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.
This commit is contained in:
Ajax Davis 2025-12-12 06:14:08 +10:00
parent 6c3267eb98
commit 2a46021341

View file

@ -379,9 +379,14 @@ async function loadAndDescribe(req: Request): Promise<Response> {
*/
async function executeTool(req: Request): Promise<Response> {
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,