Skip to content

Commit 8947c07

Browse files
authored
fix(webapp): allow resuming manually paused environments (#4120)
## Bug Manually pausing an environment works, but resuming it always fails with: > This environment is paused because your organization reached its billing limit. Resolve the limit on the billing limits settings page to resume. even when no billing limit is in effect. Once paused by a user, an environment cannot be resumed at all. ## Root cause A manual pause leaves `RuntimeEnvironment.pauseSource` as `NULL` (only billing-limit enforcement sets `BILLING_LIMIT`). The resume path in `PauseEnvironmentService` guards its `updateMany` with: ```ts NOT: { pauseSource: EnvironmentPauseSource.BILLING_LIMIT } ``` Prisma's `NOT` on a nullable field translates to SQL `!=`, which excludes `NULL` rows. So the update matches zero rows for every user-paused environment, and the zero-count branch (meant to catch a race with billing-limit pausing) returns the misleading billing-limit error. Introduced in #3996 (the guard is correct for `BILLING_LIMIT` rows; it just also swallows `NULL`). ## Fix Explicitly include `pauseSource: null` rows: ```ts OR: [ { pauseSource: null }, { NOT: { pauseSource: EnvironmentPauseSource.BILLING_LIMIT } }, ] ``` Billing-limit-paused environments are still blocked from manual resume, both by the `getManualPauseEnvironmentResult` guard and by this clause. ## Verification Reproduced locally: paused an environment via `PauseEnvironmentService` (DB shows `paused = true`, `pauseSource = NULL`), resume returned the billing-limit error with `updateMany` matching 0 rows. With the fix, resume succeeds and the environment unpauses. Billing-paused rows remain excluded by the same clause.
1 parent 478adb5 commit 8947c07

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: fix
4+
---
5+
6+
Fixed manually paused environments not being resumable. Resuming incorrectly failed with a billing-limit error even when no billing limit was in effect.

apps/webapp/app/v3/services/pauseEnvironment.server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ export class PauseEnvironmentService extends WithRunEngine {
7878
const resumed = await this._prisma.runtimeEnvironment.updateMany({
7979
where: {
8080
id: environment.id,
81-
NOT: { pauseSource: EnvironmentPauseSource.BILLING_LIMIT },
81+
// NOT on a nullable field excludes NULL rows in Prisma, which made
82+
// user-paused envs (pauseSource null) unresumable.
83+
OR: [
84+
{ pauseSource: null },
85+
{ NOT: { pauseSource: EnvironmentPauseSource.BILLING_LIMIT } },
86+
],
8287
},
8388
data: {
8489
paused: false,

0 commit comments

Comments
 (0)