supertest icon indicating copy to clipboard operation
supertest copied to clipboard

[fix] timeout doesn't call end with error

Open pbatey opened this issue 2 years ago • 0 comments

Describe the bug

Node.js version: v18.14.1

OS version: macOS Ventura 13.1

Description: A request to a non-responsive route never times-out

Actual behavior

The function passed to request(app).timeout(ms).end(fn) is never called.

Expected behavior

I expected fn to be called with a timeout error.

Code to reproduce

This never exits.

const request = require('supertest');
const assert = require('assert');
const express = require('express');

const app = express();

app.get('/user', function(req, res) {
  // res.status(200).json({ name: 'john' });
});

request(app)
  .get('/user')
  .timeout({response: 100, deadline: 100})
  .end(function(err, res) {
    if (err) throw err;
  });

Checklist

  • [X] I have searched through GitHub issues for similar issues.
  • [X] I have completely read through the README and documentation.
  • [X] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

pbatey avatar Feb 17 '23 01:02 pbatey