Skip to content

V2: Error does not returns when call GetResponse #499

@tulzke

Description

@tulzke

In the comment to the GetResponse method it says:

// GetResponse waits for Future to be filled and returns Response and error.
//
// Note: Response could be equal to nil if ClientError is returned in error.
//
// "error" could be Error, if it is error returned by Tarantool,
// or ClientError, if something bad happens in a client process.
func (fut *Future) GetResponse() (Response, error)

But the actual behavior is different. When an error returns from tarantool, I don't get it.

Here is an example of tarantool configuration:

box.cfg({
    listen = 3301,
    memtx_memory=128 * 1024 * 1024,
    read_only=false,
})

box.once('bootstrap', function()
    box.schema.user.create('test_user', { password = 'test_password' })
    box.schema.user.grant('test_user', 'read,write,execute', 'universe')
end)

api = {}
api.error = function()
    error("test error")
end

And when calling Do with CallRequest, the problem starts. I don't get an error when calling GetResponse from Feature, but only when calling Decode. The behavior differs from the method comment.

func (s *Storage) Call(
	ctx context.Context,
	functionName string,
	args any,
) (tarantool.Response, error) {
	req := tarantool.NewCallRequest(functionName).
		Context(ctx).
		Args(args)

	return s.client.Do(req).GetResponse()
}

// ...

resp, err := storage.Call(ctx, "api.error", []any{})
// test error should return here, but here is nil
if err != nil {
  return err
}

data, err := resp.Decode()
// Actually test error returns here
if err != nil {
  return err
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions