{"record":{"id":"a0708050b8c6cdeb","repo":"hashicorp/nomad","slug":"timeout-exceeded-waiting-for-process","errorCode":null,"errorMessage":"timeout exceeded waiting for process","messagePattern":"timeout exceeded waiting for process","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/winsvc/windows_service_windows.go","lineNumber":252,"sourceCode":"\tpauseDur := time.Millisecond * 250\n\tt, timerStop := helper.NewSafeTimer(pauseDur)\n\tdefer timerStop()\n\n\tfor {\n\t\tt.Reset(pauseDur)\n\n\t\tcomplete, err := condition()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif complete {\n\t\t\treturn nil\n\t\t}\n\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn fmt.Errorf(\"timeout exceeded waiting for process\")\n\t\tcase <-t.C:\n\t\t}\n\t}\n}\n","sourceCodeStart":234,"sourceCodeEnd":257,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/winsvc/windows_service_windows.go#L234-L257","documentation":"waitFor polls a Windows process/service state on a timer and returns this error when the caller's context is done before the operation reports complete. It is the timeout signal for Start, Stop, and stub-service deletion operations on Windows services.","triggerScenarios":"Start, Stop, deleteStubService, or an anonymous caller invoking waitFor when the service/process does not reach its expected state before the context deadline (ctx.Done()) fires.","commonSituations":"Service binary hangs or blocks during startup/shutdown; service depends on a slow resource; SCM stop request deadlocks; system under heavy load; the configured wait timeout is too short for slow machines.","solutions":["Inspect the Windows service/event log (sc query, Event Viewer) to find why the process is not reaching the expected state.","Increase the wait timeout/deadline passed to Start/Stop via the context.","Fix the underlying service hang: check for blocking dependencies, deadlocks, or slow disk/network at startup or shutdown.","Retry the stop/start operation after confirming the process state with the Service Control Manager."],"exampleFix":"// before\nctx := context.Background() // no deadline; or too-short timeout\n\n// after\nctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)\ndefer cancel()","handlingStrategy":"retry","validationCode":"// Before Stop/Start, check current state\nstate, _ := svc.Query()\nif state == svc.Stopped { /* skip Stop */ }","typeGuard":null,"tryCatchPattern":"err := manager.Stop(timeout)\nif err != nil && strings.Contains(err.Error(), \"timeout exceeded waiting for process\") {\n    // inspect service state/event log, optionally retry once with longer timeout\n}","preventionTips":["Use generous deadlines proportional to service startup/shutdown cost.","Watch Event Viewer for the service binary hanging.","Avoid stopping services during resource contention windows."],"tags":["windows","timeout","process","service"],"backgroundTag":"operation-timeout","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}