Skip to content

TypeScript SDK does not clear request timeout timer #31

@maxceem

Description

@maxceem

The TypeScript SDK creates a request timeout timer but does not clear it after the request finishes.

Because of that, Node.js processes can stay alive until the timeout expires, even though the request is already complete and the script has no real work left.

PR with fix: #32

Current behavior

  • create client with default config
  • make one simple request
  • request completes quickly
  • process stays alive for about 30 seconds before exit

Expected behavior

  • once the request finishes, the timeout timer should be cleared
  • the process should be able to exit immediately if no other work is pending

How to reproduce

I've created a minimal code to reproduce via gist https://gist.github.com/maxceem/7a7ac00633fd428e6061224a13036d78.

Commands to run:

git clone https://gist.github.com/7a7ac00633fd428e6061224a13036d78.git
cd 7a7ac00633fd428e6061224a13036d78
npm install
X_API_BEARER_TOKEN=your_token_here npm start

Output:

> start
> node index.mjs

sending request...
response received after 412ms
{"data":{"id":"44196397","name":"Elon Musk","username":"elonmusk"}}

response is already received; if the process hangs, the SDK left something alive

still waiting to exit... elapsed=1417ms
still waiting to exit... elapsed=2417ms
still waiting to exit... elapsed=3418ms
still waiting to exit... elapsed=4418ms
still waiting to exit... elapsed=5419ms
still waiting to exit... elapsed=6419ms
still waiting to exit... elapsed=7420ms
still waiting to exit... elapsed=8420ms
still waiting to exit... elapsed=9420ms
still waiting to exit... elapsed=10433ms
still waiting to exit... elapsed=11434ms
still waiting to exit... elapsed=12434ms
still waiting to exit... elapsed=13434ms
still waiting to exit... elapsed=14435ms
still waiting to exit... elapsed=15436ms
still waiting to exit... elapsed=16436ms
still waiting to exit... elapsed=17436ms
still waiting to exit... elapsed=18436ms
still waiting to exit... elapsed=19437ms
still waiting to exit... elapsed=20437ms
still waiting to exit... elapsed=21438ms
still waiting to exit... elapsed=22439ms
still waiting to exit... elapsed=23440ms
still waiting to exit... elapsed=24441ms
still waiting to exit... elapsed=25442ms
still waiting to exit... elapsed=26441ms
still waiting to exit... elapsed=27441ms
still waiting to exit... elapsed=28441ms
still waiting to exit... elapsed=29442ms
beforeExit after 30010ms

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