Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: propagate stream error to origin node for pushsync and retrieval protocols #4321

Merged
merged 10 commits into from
Sep 18, 2023

Conversation

istae
Copy link
Member

@istae istae commented Sep 14, 2023

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Introduces a simple mechanism to return error messages for pushsync and retrieval protocols so the origin node can log the error messages.
Bumps protocol versions.

To be included in the upcoming breaking release (ph4).

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

@istae istae changed the title feat: propagate stream error to origin node feat: propagate stream error to origin node for pushsync and retrieval protocols Sep 14, 2023
@istae istae added the on hold Temporarily halted by other development label Sep 14, 2023
@istae istae requested a review from mrekucci September 14, 2023 19:09
pkg/p2p/p2p.go Outdated
@@ -222,3 +223,30 @@ const (
func NewSwarmStreamName(protocol, version, stream string) string {
return "/swarm/" + protocol + "/" + version + "/" + stream
}

var errDelivery = errors.New("received delivery error msg")
Copy link
Contributor

@mrekucci mrekucci Sep 15, 2023

Choose a reason for hiding this comment

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

This error is not necessary, I'd recommend doing the following:

// ChunkDeliveryError contains information about a failed chunk delivery to a peer.
type ChunkDeliveryError struct {
	chunk swarm.Chunk
	peer  swarm.Address
	msg   string
}

// Error implements the error interface.
func (e *ChunkDeliveryError) Error() string {
	return fmt.Sprintf("delivery of chunk %s to peer %s: %s", e.chunk.Address(), e.peer, e.msg)
}

// NewChunkDeliveryError is a convenience constructor for ChunkDeliveryError.
func NewChunkDeliveryError(chunk swarm.Chunk, peer swarm.Address, msg string) error {
	return &ChunkDeliveryError{
		chunk: chunk,
		peer:  peer,
		msg:   msg,
	}
}

The Unwrap method is not needed in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for the suggestion, I made the change but without peer or chunk address because the existing logs take care of this

@istae istae marked this pull request as ready for review September 15, 2023 12:46
@istae istae merged commit a04109f into master Sep 18, 2023
13 checks passed
@istae istae deleted the delivery-stream-error branch September 18, 2023 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold Temporarily halted by other development pull-request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

propagate protocol errors and request forwards count back to the origin node
3 participants