Skip to content

Uncaught 'TimeoutError' exception #1460

@devjerry

Description

@devjerry

Describe the bug

  • Node.js version: 12.x.x (it's electron 5.0.7)
  • OS & version: Windows 8.1 & 10 (both 64-bit)

I'm sporadically getting uncaught 'TimeoutError' exception that is hard to reproduce in controlled manner. Happens in production where the app is making a lot of requests and running on devices with intermitted mobile internet connection.

Actual behavior

Uncaught exception:

TimeoutError: Timeout awaiting 'request' for 10000ms
    at timeoutHandler (C:\myproject\node_modules\got\dist\source\core\utils\timed-out.js:36:25)

Expected behavior

There shouldn't be any uncaught exception.

Code to reproduce

process.on('uncaughtException', function(err) {
    console.log('UNHANDLED ERROR:', err.stack);
});
    
async function getResponse() {
    try {
        return await got('https://someurl.com/', { timeout: 10000, retry: 0 }).text();
    } catch (err) {
        console.log('HANDLED ERROR:', err.stack);
    }
}

When there's some timeout error, most of the time it's handled properly:

HANDLED ERROR: RequestError: Timeout awaiting 'request' for 10000ms
    at ClientRequest.<anonymous> (C:\myproject\node_modules\got\dist\source\core\index.js:934:25)
    at Object.onceWrapper (events.js:282:20)
    at ClientRequest.emit (events.js:199:15)
    at ClientRequest.EventEmitter.emit (domain.js:469:20)
    at ClientRequest.origin.emit (C:\myproject\node_modules\@szmarczak\http-timer\dist\source\index.js:39:20)
    at Socket.socketErrorListener (_http_client.js:401:9)
    at Socket.emit (events.js:194:13)
    at Socket.EventEmitter.emit (domain.js:469:20)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at processTicksAndRejections (internal/process/task_queues.js:81:17)
    at timeoutHandler (C:\myproject\node_modules\got\dist\source\core\utils\timed-out.js:36:25)

But in some rare occasions I get this unhandled exception:

UNHANDLED ERROR: TimeoutError: Timeout awaiting 'request' for 10000ms
    at timeoutHandler (C:\myproject\node_modules\got\dist\source\core\utils\timed-out.js:36:25)

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions