Skip to content

delayConnection causes hang when used with request.abort() #867

@emilycoco

Description

@emilycoco

When using delay connection, request.abort() does not terminate the request correctly, so the test hangs until heap is full. Using request.end() instead of abort fixes the issue. Sample case:

		it('should return an error if the downstream doesn\'t return within the timeout', (done) => {
			let httpRequest = new HttpRequest(10, 1);
			nock('http://localhost:1234')
				.get('/test/abc')
				.socketDelay(100)
				.reply(200, successRsp);

			let request = httpRequest.httpGetRequest('http', 'localhost', '1234', '/test/abc');

			request
				.then(rsp => {
					throw new Error('httpGetRequest returned success unexpectedly.', rsp);
				})
				.catch(err => {
					expect(err.message).to.equal('request timed out http://localhost:1234/test/abc');
					done();
				});
		});

In code being tested:

request.setTimeout(timeout, () => {
				request.abort();
				reject(new error('request timed out ', url));
			});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions