Skip to content

Commit 7621601

Browse files
authored
fix(supervisor): drop debug-log requests cheaply when disabled (#4009)
Follow-up to #3992, which gated the send runner-side - but only for new runner images. Existing runners still POST a debug log per line. When `SEND_RUN_DEBUG_LOGS` is off (default), the route now drops the request immediately: `skipBodyParsing` skips the body read/parse, a bare handler returns 204, no wide event. The route stays registered so it avoids the `No route match` error log; the only per-request log left is the framework's `logger.debug` trace, suppressed at the default `info` level. Still counted by request metrics, and 204 is non-retryable so no retry storm. Adds a `skipBodyParsing` flag to the internal HTTP server.
1 parent f446dfa commit 7621601

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Add an optional `skipBodyParsing` flag to the internal HTTP server route definition, letting a route respond without reading or parsing the request body.

apps/supervisor/src/workloadServer/index.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -596,19 +596,16 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
596596
),
597597
});
598598
} else {
599-
// Lightweight mock route without schemas
599+
// Disabled: drop immediately without reading/parsing the body and without
600+
// any log we can't switch off. Older runners still POST per log line; the
601+
// route stays registered (an unregistered route would log "No route match"
602+
// per request) but sheds the request at minimal cost. Request metrics still
603+
// count it. 204 is non-retryable on the runner client, so no retry storm.
600604
httpServer.route("/api/v1/workload-actions/runs/:runFriendlyId/logs/debug", "POST", {
601-
handler: async (ctx) =>
602-
this.wideRoute(
603-
ctx,
604-
"logs.debug",
605-
"/api/v1/workload-actions/runs/:runFriendlyId/logs/debug",
606-
"POST",
607-
async () => {
608-
ctx.reply.empty(204);
609-
},
610-
{ highFrequency: true }
611-
),
605+
skipBodyParsing: true,
606+
handler: async (ctx) => {
607+
ctx.reply.empty(204);
608+
},
612609
});
613610
}
614611

packages/core/src/v3/serverOnly/httpServer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ interface RouteDefinition<
2929
querySchema?: TQuery;
3030
bodySchema?: TBody;
3131
keepConnectionAlive?: boolean;
32+
/** Skip reading + parsing the request body. The handler receives `body: undefined`.
33+
* Node drains any unconsumed body before the next keep-alive request. */
34+
skipBodyParsing?: boolean;
3235
handler: RouteHandler<TParams, TQuery, TBody>;
3336
}
3437

@@ -157,7 +160,7 @@ export class HttpServer {
157160
return reply.empty(405);
158161
}
159162

160-
const { handler, paramsSchema, querySchema, bodySchema, keepConnectionAlive } =
163+
const { handler, paramsSchema, querySchema, bodySchema, keepConnectionAlive, skipBodyParsing } =
161164
routeDefinition;
162165

163166
const params = this.parseRouteParams(route, url);
@@ -176,7 +179,7 @@ export class HttpServer {
176179
return reply.text("Invalid query params", 400);
177180
}
178181

179-
const body = await getJsonBody(req);
182+
const body = skipBodyParsing ? undefined : await getJsonBody(req);
180183
const parsedBody = this.optionalSchema(bodySchema, body);
181184

182185
if (!parsedBody.success) {

0 commit comments

Comments
 (0)