From 958fb02a9415721c778b66b1496b4c13bb9427bb Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 11 Dec 2025 09:57:23 +0000 Subject: [PATCH] test: close provisioner before creating workspace build Closes https://github.com/coder/internal/issues/1178 I verified the fix works by adding a `time.Sleep(100 * time.Millisecond)` between the `CreateWorkspaceBuild` and `CancelWorkspaceBuild` calls. Adding this reliably triggered the flake, and when I added the fix the flake stopped happening. --- coderd/aitasks_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coderd/aitasks_test.go b/coderd/aitasks_test.go index 31bf04c0af78c..8969895c32987 100644 --- a/coderd/aitasks_test.go +++ b/coderd/aitasks_test.go @@ -811,6 +811,12 @@ func TestTasks(t *testing.T) { require.NoError(t, err) coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID) + // If we're going to cancel the transition, we want to close the provisioner + // to stop the job completing before we can cancel it. + if tt.cancelTransition { + provisioner.Close() + } + // Given: We transition the task's workspace build := coderdtest.CreateWorkspaceBuild(t, client, workspace, tt.transition) if tt.cancelTransition {