Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.

### Fixed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move it into Changed or Added section of the CHANGELOG.md. It does not fixes anything, but looks like an improvment.


- Use wrapped context err when <-ctx.Done() case is executed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add a link to the issue in the changelog entry.

Suggested change
- Use wrapped context err when <-ctx.Done() case is executed
- Use wrapped context err when <-ctx.Done() case is executed (#457).


## [v2.4.0] - 2025-07-11

This release focuses on adding schema/user/session operations, synchronous transaction
Expand Down
10 changes: 8 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,10 @@ func (conn *Connection) newFuture(req Request) (fut *Future) {
if ctx != nil {
select {
case <-ctx.Done():
fut.SetError(fmt.Errorf("context is done (request ID %d)", fut.requestId))
fut.SetError(fmt.Errorf(
"context is done (request ID %d): %w",
fut.requestId, context.Cause(ctx),
))
Comment on lines +987 to +990
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add a test that we could check the context error existence with errors.As/errors.Is.

shard.rmut.Unlock()
return
default:
Expand Down Expand Up @@ -1026,7 +1029,10 @@ func (conn *Connection) contextWatchdog(fut *Future, ctx context.Context) {
case <-fut.done:
return
default:
conn.cancelFuture(fut, fmt.Errorf("context is done (request ID %d)", fut.requestId))
conn.cancelFuture(fut, fmt.Errorf(
"context is done (request ID %d): %w",
fut.requestId, context.Cause(ctx),
))
}
}

Expand Down
4 changes: 2 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type Tuple struct {
// Instruct msgpack to pack this struct as array, so no custom packer
// is needed.
_msgpack struct{} `msgpack:",asArray"` //nolint: structcheck,unused
_msgpack struct{} `msgpack:",asArray"` // nolint: structcheck,unused
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert the unnecessary change.

Id uint
Msg string
Name string
Expand Down Expand Up @@ -167,7 +167,7 @@ func ExamplePingRequest_Context() {
fmt.Println("Ping Error", regexp.MustCompile("[0-9]+").ReplaceAllString(err.Error(), "N"))
// Output:
// Ping Resp data []
// Ping Error context is done (request ID N)
// Ping Error context is done (request ID N): context deadline exceeded
}

func ExampleSelectRequest() {
Expand Down
14 changes: 7 additions & 7 deletions tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Member struct {
Val uint
}

var contextDoneErrRegexp = regexp.MustCompile(`^context is done \(request ID [0-9]+\)$`)
var contextDoneErrRegexp = regexp.MustCompile(`^context is done \(request ID [0-9]+\):.+$`)

func (m *Member) EncodeMsgpack(e *msgpack.Encoder) error {
if err := e.EncodeArrayLen(2); err != nil {
Expand Down Expand Up @@ -89,8 +89,8 @@ var indexNo = uint32(0)
var indexName = "primary"
var opts = Opts{
Timeout: 5 * time.Second,
//Concurrency: 32,
//RateLimit: 4*1024,
// Concurrency: 32,
// RateLimit: 4*1024,
Comment on lines +92 to +93
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert the unnecessary change.

}

const N = 500
Expand Down Expand Up @@ -888,7 +888,7 @@ func TestFutureMultipleGetTypedWithError(t *testing.T) {
}
}

///////////////////
// /////////////////
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert the unnecessary change.


func TestClient(t *testing.T) {
var err error
Expand Down Expand Up @@ -2716,7 +2716,7 @@ func TestCallRequest(t *testing.T) {
func TestClientRequestObjectsWithNilContext(t *testing.T) {
conn := test_helpers.ConnectWithValidation(t, dialer, opts)
defer conn.Close()
req := NewPingRequest().Context(nil) //nolint
req := NewPingRequest().Context(nil) // nolint
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert the unnecessary change.

data, err := conn.Do(req).Get()
if err != nil {
t.Fatalf("Failed to Ping: %s", err)
Expand Down Expand Up @@ -3269,7 +3269,7 @@ func TestClientIdRequestObjectWithNilContext(t *testing.T) {
req := NewIdRequest(ProtocolInfo{
Version: ProtocolVersion(1),
Features: []iproto.Feature{iproto.IPROTO_FEATURE_STREAMS},
}).Context(nil) //nolint
}).Context(nil) // nolint
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert the unnecessary change.

data, err := conn.Do(req).Get()
require.Nilf(t, err, "No errors on Id request execution")
require.NotNilf(t, data, "Response data not empty")
Expand All @@ -3293,7 +3293,7 @@ func TestClientIdRequestObjectWithPassedCanceledContext(t *testing.T) {
req := NewIdRequest(ProtocolInfo{
Version: ProtocolVersion(1),
Features: []iproto.Feature{iproto.IPROTO_FEATURE_STREAMS},
}).Context(ctx) //nolint
}).Context(ctx) // nolint
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, revert the unnecessary change.

cancel()
resp, err := conn.Do(req).Get()
require.Nilf(t, resp, "Response is empty")
Expand Down
Loading