nektos/act · warning

failed to close client: %w

Error message

failed to close client: %w

What it means

containerReference.Close releases the Docker API client by calling cli.Close(). The Docker SDK client almost never fails on Close, but if it does, the error is wrapped as 'failed to close client' and surfaced from the cleanup executor.

Source

Thrown at pkg/container/docker_run.go:300

		if cr.cli != nil {
			return nil
		}
		cli, err := GetDockerClient(ctx)
		if err != nil {
			return err
		}
		cr.cli = cli
		return nil
	}
}

func (cr *containerReference) Close() common.Executor {
	return func(_ context.Context) error {
		if cr.cli != nil {
			err := cr.cli.Close()
			cr.cli = nil
			if err != nil {
				return fmt.Errorf("failed to close client: %w", err)
			}
		}
		return nil
	}
}

func (cr *containerReference) find() common.Executor {
	return func(ctx context.Context) error {
		if cr.id != "" {
			return nil
		}
		result, err := cr.cli.ContainerList(ctx, client.ContainerListOptions{
			All: true,
		})
		if err != nil {
			return fmt.Errorf("failed to list containers: %w", err)
		}

View on GitHub (pinned to 4f41128141)

Solutions

  1. Check earlier log lines: the real failure usually precedes this close error
  2. Verify daemon health: docker ps after the run
  3. Restart Docker / fix DOCKER_HOST, then re-run the job
  4. If you call the API, tolerate close errors in cleanup paths (log, don't fail) since the client is being discarded anyway

Example fix

// Go caller: don't let cleanup close errors mask the run result
if err := cr.Close()(ctx); err != nil {
    log.Warnf("cleanup: %v", err) // don't return
}
Defensive patterns

Strategy: try-catch

Try / catch

// Go: closing a client we are discarding — log, don't propagate
if err := cr.Close()(ctx); err != nil {
    log.Warnf("error closing docker client (ignored): %v", err)
}

Prevention

When it happens

Trigger: cli.Close() returning a non-nil error during the finally/cleanup phase of a container run — e.g. an already-broken connection whose transport close propagates an error, or a client whose custom dialer fails on shutdown.

Common situations: Rare; typically appears at the tail of a run after an earlier connection problem (daemon died mid-run, ssh tunnel dropped), where closing the dead client also errors. It can mask the original failure in logs.

Related errors


AI-assisted analysis of nektos/act@4f41128141 (2026-08-15). Data as JSON: /api/errors/b6011ece6824ff28. Report an issue: GitHub.