{"id":"af29f7ca98afbac9","repo":"jackc/pgx","slug":"pipeline-has-unsynced-requests","errorCode":null,"errorMessage":"pipeline has unsynced requests","messagePattern":"pipeline has unsynced requests","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/pgconn.go","lineNumber":2949,"sourceCode":"}\n\nfunc (p *Pipeline) handleUnexpectedMessage(errStr string, msg pgproto3.BackendMessage) error {\n\tp.err = fmt.Errorf(\"pipeline: %s: received unexpected message type %T\", errStr, msg)\n\tp.conn.asyncClose()\n\treturn p.err\n}\n\n// Close closes the pipeline and returns the connection to normal mode.\nfunc (p *Pipeline) Close() error {\n\tif p.closed {\n\t\treturn p.err\n\t}\n\n\tp.closed = true\n\n\tif p.state.PendingSync() {\n\t\tp.conn.asyncClose()\n\t\tp.err = errors.New(\"pipeline has unsynced requests\")\n\t\tp.conn.contextWatcher.Unwatch()\n\t\tp.conn.unlock()\n\n\t\treturn p.err\n\t}\n\n\tfor p.state.ExpectedReadyForQuery() > 0 {\n\t\tresults, err := p.getResults()\n\t\tif err != nil {\n\t\t\tp.err = err\n\t\t\tvar pgErr *PgError\n\t\t\tif !errors.As(err, &pgErr) {\n\t\t\t\tp.conn.asyncClose()\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else if results == nil {\n\t\t\t// getResults returns (nil, nil) when the request queue is exhausted but\n\t\t\t// ExpectedReadyForQuery is still > 0. This can happen when FATAL errors consume","sourceCodeStart":2931,"sourceCodeEnd":2967,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/pgconn.go#L2931-L2967","documentation":"Error \"pipeline has unsynced requests\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/pgconn.go:2949 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}