ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.57k stars 1.33k forks source link

[fix] request hangs forever for non-responding servers (default timeout would fix this) #1759

Open natanavra opened 1 year ago

natanavra commented 1 year ago

Describe the bug

Superagent hangs if the server is unresponsive and the only way around is setting a timeout. This might go over many developers heads as a default timeout of 60 seconds is to be expected.

Documentation states it's expected behavior, but this is buried and is unnoticed until you actually use a timeout or have a request get freezing your app if using await.

EDIT: It seems that axios has the same behavior, so it could just be me in this case.

Node.js version: 12.22.0

OS version: Ubuntu 20.04

Description: See above

Actual behavior

request.get('tiktok.com'); will never complete

Expected behavior

should throw a timeout error after 60 seconds if no timeout was set

Code to reproduce

request.get('tiktok.com');

Checklist