gitroomhq/postiz-app · error · BadBody

X took too long to process the media, please try again

Error message

X took too long to process the media, please try again

What it means

A media processing wait loop in XProvider exceeded 8 minutes without the media reaching a ready state. The cap is deliberately below the 10-minute activity timeout: failing safely here is better than a Temporal timeout, because a retried activity would re-upload and re-publish, risking duplicates.

Source

Thrown at libraries/nestjs-libraries/src/integrations/social/x.provider.ts:1281

  ): Promise<PostResponse[]> {
    const [response] = await this.postPending(
      id,
      accessToken,
      postDetails,
      integration
    );

    let pendingData = response.pendingData;
    const started = Date.now();

    // eslint-disable-next-line no-constant-condition
    while (true) {
      // Cap below the 10-minute activity timeout of the old workflows using
      // this method: failing here is safe (the tweet is only created once the
      // media is ready), timing the activity out is not - a retried activity
      // would upload and publish again.
      if (Date.now() - started > 8 * 60 * 1000) {
        throw new BadBody(
          this.identifier,
          '{}',
          Buffer.from('{}'),
          'X took too long to process the media, please try again'
        );
      }

      const check = await this.checkPostStatus(
        accessToken,
        pendingData,
        integration
      );

      if (check.status === 'pending') {
        pendingData = check.pendingData;
        await timer(20000);
        continue;
      }

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Compress/shorten the video and retry — smaller files process well within the cap
  2. Check whether the media eventually succeeded on X before retrying, to avoid duplicates
  3. Retry the post: the tweet is only created after media is ready, so this failure is safe to retry
  4. If consistently slow, schedule posts earlier relative to send time so media processing has headroom
Defensive patterns

Strategy: retry

Validate before calling

// estimate processing time by size; reject oversized media up front
if (videoSizeMB > 200) { /* compress before scheduling */ }

Try / catch

catch (e) { if (e instanceof BadBody && e.message.includes('too long to process')) { /* safe to retry: tweet not created yet */ } throw e; }

Prevention

When it happens

Trigger: Date.now() - started > 8*60*1000 while media is still processing: slow X transcode of large videos or STATUS polling that keeps returning pending.

Common situations: Very large or long videos near X limits; X transcoder backlogs; repeated polling throttled by rate limits stretching the wait.

Related errors


AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27). Data as JSON: /api/errors/3b778b081e04bd4d. Report an issue: GitHub.