Skip to content

When axios request sets maxRedirects=0 and encounters an unresponsive website, it will not execute further. #6801

@chenxicore

Description

@chenxicore

Describe the bug

When axios request sets maxRedirects=0 and encounters an unresponsive website, it will not execute further.

To Reproduce

When axios requests to set maxRedirects=0, it encounters an unresponsive website without any printing information. When set to non-zero, error.message is aborted

tcp package
Image

http package

Image

Image

Code snippet

(async () => {
  try {
    const url = "http://192.168.12.18:10019/"
    const response = await axios.get(url, {
      maxRedirects: 0,
      headers: {"user-agent": "Mozilla/5.0 compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0"},
      timeout: 10000
    });
    console.log(response.data)
  } catch (error) {
   console.log(error.message)
  }
})();

Expected behavior

When set to 0, an exception is thrown normally

Axios Version

1.7.4

Adapter Version

HTTP1.1

Browser

No response

Browser Version

No response

Node.js Version

20.12.0

OS

debian12

Additional Library Versions

Additional context/Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue::bugThis issue is related to a bug that requires fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions