{"record":{"id":"b6011ece6824ff28","repo":"nektos/act","slug":"failed-to-close-client-w","errorCode":null,"errorMessage":"failed to close client: %w","messagePattern":"failed to close client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/container/docker_run.go","lineNumber":300,"sourceCode":"\t\tif cr.cli != nil {\n\t\t\treturn nil\n\t\t}\n\t\tcli, err := GetDockerClient(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcr.cli = cli\n\t\treturn nil\n\t}\n}\n\nfunc (cr *containerReference) Close() common.Executor {\n\treturn func(_ context.Context) error {\n\t\tif cr.cli != nil {\n\t\t\terr := cr.cli.Close()\n\t\t\tcr.cli = nil\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to close client: %w\", err)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n}\n\nfunc (cr *containerReference) find() common.Executor {\n\treturn func(ctx context.Context) error {\n\t\tif cr.id != \"\" {\n\t\t\treturn nil\n\t\t}\n\t\tresult, err := cr.cli.ContainerList(ctx, client.ContainerListOptions{\n\t\t\tAll: true,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to list containers: %w\", err)\n\t\t}\n","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/container/docker_run.go#L282-L318","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check earlier log lines: the real failure usually precedes this close error","Verify daemon health: docker ps after the run","Restart Docker / fix DOCKER_HOST, then re-run the job","If you call the API, tolerate close errors in cleanup paths (log, don't fail) since the client is being discarded anyway"],"exampleFix":"// Go caller: don't let cleanup close errors mask the run result\nif err := cr.Close()(ctx); err != nil {\n    log.Warnf(\"cleanup: %v\", err) // don't return\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go: closing a client we are discarding — log, don't propagate\nif err := cr.Close()(ctx); err != nil {\n    log.Warnf(\"error closing docker client (ignored): %v\", err)\n}","preventionTips":["Never let cleanup-path close errors fail or mask a run","Investigate the first error in the log, not the close error","Ensure daemon stability for the whole job duration"],"tags":["docker","resource-cleanup","client-lifecycle"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}