fix(schedule): await cloud schedule registration and validate jobs service response (#5139) - #5450
fliptrigga13 wants to merge 1 commit into
Conversation
| if (newSchedule?.enabled) { | ||
| if (IS_CLOUD) { | ||
| schedule({ | ||
| await schedule({ |
There was a problem hiding this comment.
Registration failure leaves duplicates
When cloud registration fails, the enabled schedule has already been committed to the database, so this awaited call returns an error without removing that row. The dialog remains open and permits another submission, which inserts a schedule with a new ID. Repeated attempts can therefore create duplicate enabled schedules with no registered cloud job.
| if (!result.ok) { | ||
| const errorText = await result.text().catch(() => ""); | ||
| throw new Error( | ||
| `Failed to remove schedule job: ${result.statusText} ${errorText}`.trim(), | ||
| ); |
There was a problem hiding this comment.
Remote failures leave divergence
Callers commit local updates or deletions before these new non-2xx errors are thrown. For example, schedule deletion removes the database row before awaiting removeJob; if the jobs service rejects the request, the mutation fails while the remote job remains active, and the deleted record is unavailable for a normal retry. The same ordering around updateJob can leave locally committed settings that the remote service never accepted.
|
Closing this PR as part of a bulk cleanup of automated/bot-generated submissions from this account. These PRs were opened in a tight, non-interactive burst (most within a ~2 hour window) with no accompanying human review, discussion, or testing evidence, so we're not able to verify the correctness or safety of the changes as submitted. If any of the underlying issue(s) this PR references are still valid, please feel free to open a new PR with a human review process behind it, and we're happy to take another look. |
Summary
Resolves #5139: Dokploy Cloud application schedule runs manually but never executes automatically.
Root Cause
apps/dokploy/server/api/routers/schedule.ts, thecreatemutation called the cloudschedule(...)utility withoutawait:schedule(...)was not awaited, the mutation returnednewScheduleimmediately. In serverless/cloud environments, detached background network promises may be terminated or suspended before completing the HTTP POST to${process.env.JOBS_URL}/create-backup.apps/dokploy/server/utils/backup.ts,schedule(...),updateJob(...), andremoveJob(...)performed HTTP requests viafetchbut did not checkresult.ok. As a result, non-2xx HTTP responses (e.g. 400, 500) were silently returned as JSON without throwing, preventing callers from detecting registration failures.backup.tsreferenced@dokploy/server/indexinstead of the root package export@dokploy/server.Fix
await schedule({ ... })inscheduleRouter.creatematching the pattern used inupdateJoband other routers.!result.okcheck inschedule(...),updateJob(...), andremoveJob(...)to throw a descriptive error containing HTTP status and response message on failure.@dokploy/serverpackage import inapps/dokploy/server/utils/backup.ts.Test Plan
apps/dokploy/__test__/schedule/cloud-schedule-registration.test.ts(6/6 passed, 100% pass rate).cancelJobsbatch removal in cloud mode.Closes #5139
The PR is not yet safe to merge because cloud failures can leave committed local records inconsistent with the jobs service.
Summary
Reviews (1) · Last reviewed commit: "fix(schedule): await cloud schedule regi..."