{"record":{"id":"a11ff432e51cade4","repo":"hashicorp/terraform","slug":"interrupted-last-error-v","errorCode":null,"errorMessage":"interrupted - last error: %v","messagePattern":"interrupted - last error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/communicator/communicator.go","lineNumber":164,"sourceCode":"\t\t}\n\t}()\n\n\t// Wait for completion\n\tselect {\n\tcase <-ctx.Done():\n\tcase <-doneCh:\n\t}\n\n\tvar lastErr error\n\t// Check if we got an error executing\n\tif ev, ok := errVal.Load().(errWrap); ok {\n\t\tlastErr = ev.E\n\t}\n\n\t// Check if we have a context error to check if we're interrupted or timeout\n\tswitch ctx.Err() {\n\tcase context.Canceled:\n\t\treturn fmt.Errorf(\"interrupted - last error: %v\", lastErr)\n\tcase context.DeadlineExceeded:\n\t\treturn fmt.Errorf(\"timeout - last error: %v\", lastErr)\n\t}\n\n\tif lastErr != nil {\n\t\treturn lastErr\n\t}\n\treturn nil\n}\n","sourceCodeStart":146,"sourceCodeEnd":174,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/communicator/communicator.go#L146-L174","documentation":"communicator.Retry at communicator.go:89 runs function f with exponential backoff until it succeeds, returns a Fatal error, or the context ends. If the context was canceled (context.Canceled) the select at communicator.go:163 returns this with the last retryable error attached. This represents an interruption — typically user-initiated (Ctrl-C).","triggerScenarios":"The retry context is canceled mid-backoff — the user pressed Ctrl-C, a parent context was canceled, or the provisioner was torn down.","commonSituations":"User interrupted a long-running provisioner; test harness canceled the context; orchestration aborted the apply.","solutions":["If the interrupt was intentional, no fix is needed — this is expected behavior on cancellation.","If unexpected, find what is canceling the context (parent process, signal handler, timeout wrapper).","Make the remote target more reliable so fewer retries are needed before an intentional cancel."],"exampleFix":"// before — Ctrl-C during provisioner\n^C\nError: interrupted - last error: dial tcp 10.0.0.5:22: connect: connection refused\n\n// after — no code fix; this is the expected result of cancellation. To avoid accidental cancels, run non-interactively:\n$ terraform apply -auto-approve","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"err := communicator.Retry(ctx, func() error { return c.Connect(o) })\nif err != nil && errors.Is(ctx.Err(), context.Canceled) {\n    // graceful: the run was interrupted; log and exit cleanly\n    return nil\n}","preventionTips":["Only cancel the retry context when you genuinely intend to abort.","Propagate cancellation cleanly so users see 'interrupted' rather than a hung process.","Log the last error so the cause of the failed retries is not lost."],"tags":["terraform","provisioner","retry","cancellation","context"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}