pulumi/pulumi · warning

failed to cancel language runtime: %w

Error message

failed to cancel language runtime: %w

What it means

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.

Source

Thrown at sdk/go/common/resource/plugin/langruntime_plugin.go:988

	return res.ImportInstructions, nil
}

func (h *langhost) Cancel(ctx context.Context) error {
	label := fmt.Sprintf("langhost[%v].Cancel()", h.runtime)
	logging.V(7).Infof("%s executing", label)

	_, err := h.client.Cancel(ctx, &emptypb.Empty{})
	if err != nil {
		status, ok := status.FromError(err)
		if ok && status.Code() == codes.Unimplemented {
			if h.plug != nil {
				h.plug.shutdownAcknowledged.Store(true)
			}
			logging.V(7).Infof("%s not implemented by language runtime, skipping", label)
			return nil
		}

		return fmt.Errorf("failed to cancel language runtime: %w", err)
	}

	if h.plug != nil {
		h.plug.shutdownAcknowledged.Store(true)
	}
	logging.V(7).Infof("%s success", label)
	return nil
}

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Check whether the language host crashed earlier in the logs — the cancel failure is usually secondary to that crash.
  2. Retry the command; transient Unavailable during teardown is often harmless.
  3. Increase timeouts (e.g. PULUMI_CANCEL_GRPC_DEADLINE_MS or relevant env tuning) if Cancel routinely exceeds its deadline.
  4. If it persists, force-remove orphaned plugin processes and reinstall the language SDK.
Defensive patterns

Strategy: try-catch

Try / catch

if err := host.Cancel(ctx); err != nil {
    if status.Code(err) == codes.Unimplemented { return nil }
    log.Warnf("graceful cancel failed (%v); relying on process kill", err)
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/58fd0aac3a650be4. Report an issue: GitHub.