Skip to content

The timeoutErrorMessage property in config not work with Node.js #3580

@duibu05

Description

@duibu05

Describe the bug

The timeoutErrorMessage property in config not work with Node.js, expected custom error message, got "timeout of *ms exceeded"

To Reproduce

it('should respect the timeoutErrorMessage property', function (done) {

    server = http.createServer(function (req, res) {
      setTimeout(function () {
        res.end();
      }, 1000);
    }).listen(4444, function () {
      var success = false, failure = false;
      var error;

      axios.get('http://localhost:4444/', {
        timeout: 250,
        timeoutErrorMessage: 'oops, timeout',
      }).then(function (res) {
        success = true;
      }).catch(function (err) {
        error = err;
        failure = true;
      });

      setTimeout(function () {
        assert.strictEqual(success, false, 'request should not succeed');
        assert.strictEqual(failure, true, 'request should fail');
        assert.strictEqual(error.code, 'ECONNABORTED');
        assert.strictEqual(error.message, 'oops, timeout');
        done();
      }, 300);
    });
});

Expected behavior

Expected: oops, timeout
Got: timeout of 250ms exceeded

Environment

  • Axios Version: 0.21.1
  • Adapter: HTTP
  • Browser: none
  • Browser Version: none
  • Node.js Version: 12.19.0
  • OS: MacOS 10.14
  • Additional Library Versions: none

Additional context/Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions