{"record":{"id":"6ca8c0627dad5fcc","repo":"hashicorp/packer","slug":"interrupt-detected-quitting-waiting-for-machine-t","errorCode":null,"errorMessage":"Interrupt detected, quitting waiting for machine to restart","messagePattern":"Interrupt detected, quitting waiting for machine to restart","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"provisioner/windows-restart/provisioner.go","lineNumber":205,"sourceCode":"\t\t// or an interrupt to come through.\n\t\tselect {\n\t\tcase <-waitDone:\n\t\t\tif err != nil {\n\t\t\t\tui.Error(fmt.Sprintf(\"Error waiting for machine to restart: %s\", err))\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tui.Say(\"Machine successfully restarted, moving on\")\n\t\t\tclose(p.cancel)\n\t\t\tbreak WaitLoop\n\t\tcase <-timeout:\n\t\t\terr := fmt.Errorf(\"Timeout waiting for machine to restart.\")\n\t\t\tui.Error(err.Error())\n\t\t\tclose(p.cancel)\n\t\t\treturn err\n\t\tcase <-p.cancel:\n\t\t\tclose(waitDone)\n\t\t\treturn fmt.Errorf(\"Interrupt detected, quitting waiting for machine to restart\")\n\t\t}\n\t}\n\treturn nil\n\n}\n\nvar waitForCommunicator = func(ctx context.Context, p *Provisioner) error {\n\trunCustomRestartCheck := true\n\tif p.config.RestartCheckCommand == DefaultRestartCheckCommand {\n\t\trunCustomRestartCheck = false\n\t}\n\t// This command is configurable by the user to make sure that the\n\t// vm has met their necessary criteria for having restarted. If the\n\t// user doesn't set a special restart command, we just run the\n\t// default as cmdModuleLoad below.\n\tcmdRestartCheck := &packersdk.RemoteCmd{Command: p.config.RestartCheckCommand}\n\tlog.Printf(\"Checking that communicator is connected with: '%s'\",\n\t\tcmdRestartCheck.Command)","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/windows-restart/provisioner.go#L187-L223","documentation":"The windows-restart provisioner's wait loop also selects on an internal cancel channel (p.cancel). When a cancel is signaled — typically because the enclosing build was interrupted via Ctrl-C or the context was cancelled — the loop abandons waiting and returns this error. It is the provisioner's way of unwinding cleanly on user/environment-initiated interruption rather than a guest failure.","triggerScenarios":"The wait loop's `<-p.cancel` case fires: the user pressed Ctrl-C during `packer build` while waiting for the Windows machine to restart, or another path closed p.cancel (notably, the success path also closes p.cancel, so a racing/goroutine-leak scenario can surface this error unexpectedly).","commonSituations":"User aborts a build mid-reboot; CI job cancelled/timed out externally killing packer; reruns or tests where p.cancel is closed concurrently causing the interrupt branch to trigger.","solutions":["Let the build run to completion or press Ctrl-C only when you intend to abort","Re-run the build after an intended interruption; the machine state may need cleanup","If this appears without user interruption, ensure only one Provision run per provisioner instance and update to a recent Packer version for channel-handling fixes","Adjust CI timeouts so external job cancellation does not strike mid-restart"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := p.Provision(ctx, ui, comm, generatedData)\nif err != nil && strings.Contains(err.Error(), \"Interrupt detected\") {\n    // treat as user cancellation: clean up and stop gracefully\n    return\n}","preventionTips":["Avoid Ctrl-C/CI cancellation during the restart window; size CI timeouts accordingly","Run one Provision per provisioner instance to avoid p.cancel channel races","Handle cancellation gracefully in wrappers: release guest resources before exiting","Keep Packer updated for improvements to cancel-channel handling"],"tags":["provisioner","windows-restart","interrupt","cancellation","windows"],"backgroundTag":"build-cancelled-by-interrupt","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}