{"record":{"id":"58fd0aac3a650be4","repo":"pulumi/pulumi","slug":"failed-to-cancel-language-runtime-w-58fd0a","errorCode":null,"errorMessage":"failed to cancel language runtime: %w","messagePattern":"failed to cancel language runtime: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdk/go/common/resource/plugin/langruntime_plugin.go","lineNumber":988,"sourceCode":"\treturn res.ImportInstructions, nil\n}\n\nfunc (h *langhost) Cancel(ctx context.Context) error {\n\tlabel := fmt.Sprintf(\"langhost[%v].Cancel()\", h.runtime)\n\tlogging.V(7).Infof(\"%s executing\", label)\n\n\t_, err := h.client.Cancel(ctx, &emptypb.Empty{})\n\tif err != nil {\n\t\tstatus, ok := status.FromError(err)\n\t\tif ok && status.Code() == codes.Unimplemented {\n\t\t\tif h.plug != nil {\n\t\t\t\th.plug.shutdownAcknowledged.Store(true)\n\t\t\t}\n\t\t\tlogging.V(7).Infof(\"%s not implemented by language runtime, skipping\", label)\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"failed to cancel language runtime: %w\", err)\n\t}\n\n\tif h.plug != nil {\n\t\th.plug.shutdownAcknowledged.Store(true)\n\t}\n\tlogging.V(7).Infof(\"%s success\", label)\n\treturn nil\n}\n","sourceCodeStart":970,"sourceCodeEnd":997,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/go/common/resource/plugin/langruntime_plugin.go#L970-L997","documentation":"When shutting down a language host, the engine calls Cancel (or Shutdown) over gRPC. If the call fails with an error other than Unimplemented (which is skipped gracefully), the engine reports \"failed to cancel language runtime\" wrapping the gRPC error. The plugin may still terminate via process kill, but this signals the graceful cancellation path failed.","triggerScenarios":"Calling Cancel/Shutdown on the language host during `pulumi destroy`, Ctrl+C, or deployment teardown when the host process has already exited or the gRPC stream is broken (Unavailable, DeadlineExceeded).","commonSituations":"Language host crashed mid-deployment so cancellation hits a dead connection; very slow Cancel calls hitting the deadline; force-killed processes during CI cancellation; network/process supervision issues in containers.","solutions":["Check whether the language host crashed earlier in the logs — the cancel failure is usually secondary to that crash.","Retry the command; transient Unavailable during teardown is often harmless.","Increase timeouts (e.g. PULUMI_CANCEL_GRPC_DEADLINE_MS or relevant env tuning) if Cancel routinely exceeds its deadline.","If it persists, force-remove orphaned plugin processes and reinstall the language SDK."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := host.Cancel(ctx); err != nil {\n    if status.Code(err) == codes.Unimplemented { return nil }\n    log.Warnf(\"graceful cancel failed (%v); relying on process kill\", err)\n}","preventionTips":["Investigate earlier host crashes — cancel failures are usually secondary","Tune cancellation deadlines for slow language runtimes","Monitor for orphaned plugin processes after failed runs"],"tags":["grpc","shutdown","language-host","cancellation"],"backgroundTag":"grpc-cancel-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}