Skip to content

Commit 358d338

Browse files
committed
chore(supervisor): skip schema parsing when debug logs disabled
1 parent aad7840 commit 358d338

File tree

1 file changed

+26
-18
lines changed
  • apps/supervisor/src/workloadServer

1 file changed

+26
-18
lines changed

apps/supervisor/src/workloadServer/index.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
125125
}
126126

127127
private createHttpServer({ host, port }: { host: string; port: number }) {
128-
return new HttpServer({
128+
const httpServer = new HttpServer({
129129
port,
130130
host,
131131
metrics: {
@@ -346,23 +346,6 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
346346
},
347347
}
348348
)
349-
.route("/api/v1/workload-actions/runs/:runFriendlyId/logs/debug", "POST", {
350-
paramsSchema: WorkloadActionParams.pick({ runFriendlyId: true }),
351-
bodySchema: WorkloadDebugLogRequestBody,
352-
handler: async ({ req, reply, params, body }) => {
353-
reply.empty(204);
354-
355-
if (!env.SEND_RUN_DEBUG_LOGS) {
356-
return;
357-
}
358-
359-
await this.workerClient.sendDebugLog(
360-
params.runFriendlyId,
361-
body,
362-
this.runnerIdFromRequest(req)
363-
);
364-
},
365-
})
366349
.route("/api/v1/workload-actions/deployments/:deploymentId/dequeue", "GET", {
367350
paramsSchema: z.object({
368351
deploymentId: z.string(),
@@ -387,6 +370,31 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
387370
reply.json(dequeueResponse.data satisfies WorkloadDequeueFromVersionResponseBody);
388371
},
389372
});
373+
374+
if (env.SEND_RUN_DEBUG_LOGS) {
375+
httpServer.route("/api/v1/workload-actions/runs/:runFriendlyId/logs/debug", "POST", {
376+
paramsSchema: WorkloadActionParams.pick({ runFriendlyId: true }),
377+
bodySchema: WorkloadDebugLogRequestBody,
378+
handler: async ({ req, reply, params, body }) => {
379+
reply.empty(204);
380+
381+
await this.workerClient.sendDebugLog(
382+
params.runFriendlyId,
383+
body,
384+
this.runnerIdFromRequest(req)
385+
);
386+
},
387+
});
388+
} else {
389+
// Lightweight mock route without schemas
390+
httpServer.route("/api/v1/workload-actions/runs/:runFriendlyId/logs/debug", "POST", {
391+
handler: async ({ reply }) => {
392+
reply.empty(204);
393+
},
394+
});
395+
}
396+
397+
return httpServer;
390398
}
391399

392400
private createWebsocketServer() {

0 commit comments

Comments
 (0)