Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/httpserver-skip-body-parsing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Add an optional `skipBodyParsing` flag to the internal HTTP server route definition, letting a route respond without reading or parsing the request body.
21 changes: 9 additions & 12 deletions apps/supervisor/src/workloadServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,19 +596,16 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
),
});
} else {
// Lightweight mock route without schemas
// Disabled: drop immediately without reading/parsing the body and without
// any log we can't switch off. Older runners still POST per log line; the
// route stays registered (an unregistered route would log "No route match"
// per request) but sheds the request at minimal cost. Request metrics still
// count it. 204 is non-retryable on the runner client, so no retry storm.
httpServer.route("/api/v1/workload-actions/runs/:runFriendlyId/logs/debug", "POST", {
handler: async (ctx) =>
this.wideRoute(
ctx,
"logs.debug",
"/api/v1/workload-actions/runs/:runFriendlyId/logs/debug",
"POST",
async () => {
ctx.reply.empty(204);
},
{ highFrequency: true }
),
skipBodyParsing: true,
handler: async (ctx) => {
ctx.reply.empty(204);
},
});
}

Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/v3/serverOnly/httpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ interface RouteDefinition<
querySchema?: TQuery;
bodySchema?: TBody;
keepConnectionAlive?: boolean;
/** Skip reading + parsing the request body. The handler receives `body: undefined`.
* Node drains any unconsumed body before the next keep-alive request. */
skipBodyParsing?: boolean;
handler: RouteHandler<TParams, TQuery, TBody>;
}

Expand Down Expand Up @@ -157,7 +160,7 @@ export class HttpServer {
return reply.empty(405);
}

const { handler, paramsSchema, querySchema, bodySchema, keepConnectionAlive } =
const { handler, paramsSchema, querySchema, bodySchema, keepConnectionAlive, skipBodyParsing } =
routeDefinition;

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

const body = await getJsonBody(req);
const body = skipBodyParsing ? undefined : await getJsonBody(req);
const parsedBody = this.optionalSchema(bodySchema, body);

if (!parsedBody.success) {
Expand Down
Loading