Skip to content

Conversation

baldwin-sudo
Copy link


// cap the max blocking time for the request call
ctx, cancel := context.WithTimeout(ctx, NetworkHeadRequestTimeout)
ctx, cancel := context.WithTimeoutCause(ctx, NetworkHeadRequestTimeout, errors.New("network head request time out "))
Copy link
Member

Choose a reason for hiding this comment

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

Extract error to a global public var

p.peerLk.RUnlock()

ctx, cancel := context.WithTimeout(ctx, time.Second*5)
ctx, cancel := context.WithTimeoutCause(ctx, time.Second*5, errors.New("dumping peers timeout "))
Copy link
Member

Choose a reason for hiding this comment

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

To get the cause, it needs to be unwrapped via context.Cause. The context is used for the Put operation, so we should unwrap the cause in the log next to it.

}

ctx, cancel := context.WithTimeout(serv.ctx, serv.Params.RequestTimeout)
ctx, cancel := context.WithTimeoutCause(serv.ctx, serv.Params.RequestTimeout, errors.New("server "+string(serv.host.ID())+": request timed out "))
Copy link
Member

Choose a reason for hiding this comment

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

Similarly here, we need to unwrap the cause for this to have any effect.

@baldwin-sudo
Copy link
Author

alright , on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants