Skip to content

Return context error after it is done #457

@Maximilan4

Description

@Maximilan4

Setup: http server, making tarantool requests with context cancelation.
When connection closed from client side, request context.Context canceled. Such errors like context.Canceled are handled by out side, and converting to response with 499 status code.

Problem:
One of ctx.Done() handlers - https://github.com/tarantool/go-tarantool/blob/master/connection.go#L987
Connector returns own error on finished context. This is not static err, and it is a tricky kind to handle it. This leads to wrong 500 status code errors in logs and metrics.

Proposal:
Return a wrapped context.Cause result, for example:

select {
		case <-ctx.Done():
			fut.SetError(fmt.Errorf("context is done (request ID %d): %w", fut.requestId, context.Cause(ctx)))
}

This will allow to handle internal context error or custom, given from context.WithCancelCause cancel func.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions