Skip to content

Preview Deployment limit check blocks updating existing previews #4074

Closed
0x00-sys/dokploy
#103

Description

@stevenkissack

To Reproduce

  1. Configure an application with preview deployment limit set to 3
  2. Open 3 PRs that trigger preview deployments
  3. Push a commit to one of the open PRs
  4. The preview does not rebuild, the webhook delivery shows 200 in Github, but no build is queued
  5. Deleting an old preview deployment to get back under the limit restores rebuild behaviour

Current vs. Expected behavior

Expected
Pushing a commit to a PR with an existing preview deployment should rebuild that preview. The preview limit should only prevent new previews from being created.

Actual
The limit check in the webhook handler runs early & silently drops the update event, leaving the preview build stale

Provide environment information

Operating System: Ubuntu 24.04 LTS
Arch: amd64
Dokploy version: 0.28.7

What applications/services are you trying to deploy?
- Multiple React apps with GitHub App integration and label-based preview deployments

Which area(s) are affected? (Select all that apply)

Application

Are you deploying the applications where Dokploy is installed or on a remote server?

Same server where Dokploy is installed

Additional context

Secondary issues in the same check when researching the root cause

  • Preview limit defaults to 0 instead of the db schema default of 3
  • Limit comparison allows one extra preview beyond the limit

I've created a PR in my fork to show the fix, but I have yet to test this on my server so refrained from submitting upstream

Will you send a PR to fix it?

Maybe, need help

Activity

  1. dosubot commented on Mar 26, 2026

    @dosubot

    Hi @stevenkissack! I'm Dosu and I’m helping the dokploy team.

    Your analysis is spot on! I found the exact code causing this issue.

    Root Cause: The limit check at lines 474-477 of github.ts runs before checking if a preview already exists:

    const previewLimit = app?.previewLimit || 0;
    if (app?.previewDeployments?.length > previewLimit) {
        continue;
    }

    The existence check at lines 478-494 that determines update vs. create never gets reached when at the limit.

    Your secondary findings are also confirmed:

    1. || 0 fallback should be ?? 3 to respect the DB schema default
    2. > should be >= to enforce the exact limit

    Your fork's fix approach (moving the limit check to only apply when creating new previews) is the right solution. Feel free to open the upstream PR—the fix looks well-scoped!

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dokploy with Dosu Add Dosu to your team

  2. Siumauricio commented on Aug 4, 2026

    @Siumauricio
    Contributor

    Confirmed on v0.29.13 by reading the webhook handler — your description of the mechanism is accurate.

    pages/api/deploy/github.ts:

    const previewLimit = app?.previewLimit || 0;
    if (app?.previewDeployments?.length > previewLimit) {
        continue;                                    // ← drops the event entirely
    }
    const previewDeploymentResult =
        await findPreviewDeploymentByApplicationId(app.applicationId, prId);

    The limit check runs before the lookup that would tell us whether this PR already has a preview, so a push to an existing preview is skipped with no build queued and no error — the webhook still returns 200 to GitHub, which is why delivery looks healthy. Moving the check so it only guards the createPreviewDeployment path would fix it.

    One extra detail worth noting for the fix: the comparison is > rather than >=, so with previewLimit = 3 the fourth preview is still created and only the fifth is blocked. Whoever changes this should decide whether the limit is meant to be inclusive; fixing the ordering without the boundary would keep an off-by-one.

    Confirmed; keeping open.

  3. added a commit that references this issue on Aug 18, 2026
    98dbc59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions