eggjs / eggjs/egg

[Feature Request] HttpClient should retry request when server closes connection

Open
#4,487 2 comments 1 reaction 0 assignees View on GitHub
Inactive
Dominant language
TypeScript
Stars
19k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

## Background
When server closes connection at unfortunate time ([keep-alive race](https://code-examples.net/en/q/28a8069)), the http client will throw a `ECONNRESET` error.

Under this circumstance, `agentkeepalive` add `req.reusedSocket` to detect whether request is failed because reusing tcp connection.

## Proposal
Add options `retryWhenResuedSocketFail` to `HttpClient` for whether retry request when get `ECONNREST` and `req.reusedSocket` is `true`. This options default value is `true`.

Seems Chrome do the same thing: https://codereview.chromium.org/303443011

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.