Skip to content

[ERROR] Code : 413 (Payload Too Large) #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eik-1 opened this issue Mar 21, 2025 · 3 comments
Closed

[ERROR] Code : 413 (Payload Too Large) #346

eik-1 opened this issue Mar 21, 2025 · 3 comments
Assignees

Comments

@eik-1
Copy link

eik-1 commented Mar 21, 2025

I've set a webhook handler to get logs for my trainings:

const training = await replicate.trainings.create(
      "ostris",
      "flux-dev-lora-trainer",
      "b6af14222e6bd9be257cbc1ea4afda3cd0503e1133083b9d1de0364d8568e6ef",
      {
        destination: <Destination>,
        input: {
          steps: 1500,
          lora_rank: 16,
          optimizer: "adamw8bit",
          batch_size: 1,
          resolution: "512,768,1024",
          autocaption: true,
          input_images: fileUrl,
          trigger_word: triggerWord,
          learning_rate: 0.0004,
          wandb_project: "flux_train_replicate",
        },
        webhook: <REPLICATE_WEBHOOK_URL>,
        webhook_events_filter: ["start", "completed", "output", "logs"],
      }
);

Handler:

export async function replicateWebhook(req, res) {
  const secret = <REPLICATE_WEBHOOK_SECRET>;
  if (!secret) {
    console.log(
      "Skipping webhook validation. To validate webhooks, set REPLICATE_WEBHOOK_SIGNING_SECRET"
    );
    const body = await req.json();
    return res.json(
      { detail: "Webhook received (but not validated)" },
      { status: 200 }
    );
  }

  const webhookIsValid = await validateWebhook(req, secret);
  if (!webhookIsValid) {
    return res.json({ detail: "Webhook is invalid" }, { status: 401 });
  }

  const webhookData = JSON.parse(req.body.toString());
  const { id, output, status } = webhookData;
  console.log("From Replicate: ", id, status);

  /* WORKING WITH THE DATA RECIEVED"

  return res.json(
      { detail: "Webhook received and succeeded" },
      { status: 200 }
  );
}

Using the webhooks routes:
app.use("/replicateWebhook", replicateWebhookRoutes);

I just need the output, status and the id from the request.body but it says that the Payload is too large.
Need help

@aron
Copy link
Contributor

aron commented Mar 26, 2025

Hi thanks for reporting. I can see that your webhooks are hitting a size threshold, we're looking into the issue.

@aron
Copy link
Contributor

aron commented Mar 26, 2025

We've looked into the issue and it appears that we are attempting to send the webhook and the recipient server is responding with the 413.

Is there anything in your setup, middleware, hosting provider etc that might be limiting the size of requests to your app?

@aron aron self-assigned this Mar 26, 2025
@aron
Copy link
Contributor

aron commented Apr 30, 2025

I'm closing this for now. Please reopen if you have further issues.

@aron aron closed this as completed Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants