Skip to content

Properly wrap context-related NeoFS Client errors #624

Closed

Description

@AnnaShaleva

Is your feature request related to a problem? Please describe.

I'm using NeoFS Client to perform object get and object search requests with cancellation context. If context is cancelled by the caller's code, the rpc error: code = Canceled desc = context canceled error is returned from this method:

func (x *ObjectListReader) Iterate(f func(oid.ID) bool) error {

This error is expected since context was explicitly cancelled. However, I can't identify this error with if errors.Is(err, context.Canceled) because it's not a wrapped error.

Describe the solution you'd like

context.Canceled and context.DeadlineExceeded should be recognizable by NeoFS client and should be returned as wrapped errors from all clients methods that work with context. We're at Go 1.22, multierror wrapping is supported.

Describe alternatives you've considered

Leave it as is, but it leads to the following code on the caller's side:

// isContextCanceledErr returns whether error is a wrapped [context.Canceled].
func isContextCanceledErr(err error) bool {
	return errors.Is(err, context.Canceled) ||
		strings.Contains(err.Error(), "context canceled")
}

Activity

  1. added
    enhancementImproving existing functionality
    U3Regular
    S4Routine
    I2Regular impact
    on Sep 10, 2024
  2. roman-khimov commented on Sep 10, 2024

    @roman-khimov
    Member

    But if it happens server-side it can be a problem.

  3. added this to the v1.0.0-rc25 milestone on Oct 27, 2026
  4. added a commit that references this issue on Oct 30, 2026
    e883d0c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

I2Regular impactS4RoutineU3RegularenhancementImproving existing functionality

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions