Skip to content

Switch from net.Error.Temporary to net.Error.Timeout #270

@gavv

Description

@gavv

Currently httpexpect.Request has 4 retry policies:

  • DontRetry
  • RetryTemporaryNetworkErrors
  • RetryTemporaryNetworkAndServerErrors
  • RetryAllErrors

RetryTemporaryNetworkErrors and RetryTemporaryNetworkAndServerErrors use net.Error.Temporary to identify temporary network errors (see Request.shouldRetry). This method were deprecated in recent go versions:

// An Error represents a network error.
type Error interface {
	error
	Timeout() bool // Is the error a timeout?

	// Deprecated: Temporary errors are not well-defined.
	// Most "temporary" errors are timeouts, and the few exceptions are surprising.
	// Do not use this method.
	Temporary() bool
}

Hence, we should migrate from Temporary to Timeout, but without breaking compatibility.

Steps:

  • introduce two new retry policies: RetryTimeoutErrors, RetryTimeoutAndServerErrors
  • RetryTimeoutErrors should work like RetryTemporaryNetworkErrors, but it should use net.Error.Timeout
  • RetryTimeoutAndServerErrors should work like RetryTemporaryNetworkAndServerErrors, but it should use net.Error.Timeout
  • mark RetryTemporaryNetworkErrors and RetryTemporaryNetworkAndServerErrors as deprecated and suggest to use corresponding new policies instead
  • update tests to work with new policies; exclude deprecated policies from tests because these tests are huge already

We will remove deprecated policies in v3.

Metadata

Metadata

Assignees

Labels

featureNew feature or requesthelp wantedContributions are welcomeimportantImportant task

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions