Skip to content

Commit

Permalink
chore(github): Add extended timeout and error responses for webhooks
Browse files Browse the repository at this point in the history
- Set maxDuration to 300 seconds (5 minutes) for GitHub webhook handlers
- Add explicit error responses when command or installation is not found
- Include payload details in error messages for better debugging

The changes improve webhook reliability by allowing longer processing time
and providing more detailed error feedback for failed webhook requests.
  • Loading branch information
toyamarinyon committed Dec 25, 2024
1 parent 631f237 commit 2c1cf02
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/webhooks/github/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import type { Execution, Graph } from "../../(playground)/p/[agentId]/types";
import { parseCommand } from "./command";
import { assertIssueCommentEvent, createOctokit } from "./utils";

// Extend the max duration of the server actions from this page to 5 minutes
// https://vercel.com/docs/functions/runtimes#max-duration
export const maxDuration = 300;

export async function POST(request: NextRequest) {
if (process.env.GITHUB_APP_WEBHOOK_SECRET === undefined) {
throw new Error("GITHUB_APP_WEBHOOK_SECRET is not set");
Expand All @@ -37,10 +41,16 @@ export async function POST(request: NextRequest) {

const command = parseCommand(payload.comment.body);
if (command === null) {
return;
return new Response(
`Command not found. payload: ${JSON.stringify(payload)}`,
{ status: 400 },
);
}
if (payload.installation === undefined) {
return;
return new Response(
`Installation not found. payload: ${JSON.stringify(payload)}`,
{ status: 400 },
);
}
const octokit = await createOctokit(payload.installation.id);

Expand Down

0 comments on commit 2c1cf02

Please sign in to comment.