BUG: API deploy handler uses request context — deployment cancelled on client disconnect #105
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: HIGH
File & Line
internal/handlers/api.go:345Description
HandleAPITriggerDeploycallsh.deploy.Deploy(request.Context(), ...)directly with the HTTP request context. When the API client disconnects (or times out),request.Context()is cancelled, which propagates into the deploy service and cancels the build/deploy mid-operation.The HTML handler (
HandleAppDeployinapp.go:355) correctly usescontext.WithoutCancel(request.Context())and runs the deployment in a goroutine.Impact
Any API-triggered deployment will be cancelled if the HTTP client disconnects before the build finishes (which can take 30+ minutes). The deployment will be left in a partially-built state. This makes the API deploy endpoint essentially unreliable.
Suggested Fix
Use
context.WithoutCanceland run in a goroutine, same as the HTML handler. Return 202 Accepted immediately (which it already does, but after the deploy starts synchronously).