Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timeout issue when following redirects #217

Merged
merged 2 commits into from
Aug 9, 2017
Merged

Conversation

laittg
Copy link
Contributor

@laittg laittg commented Jul 19, 2017

When following redirects the timer variable will be created multiple times if open_timeout and/or read_timeout is set (>0).

This makes the script always wait until setTimeout is invoked, thus always emit the timeout event.

Quick fix:

  • clearTimeout before following redirects
  • also invoke done() inside setTimeout() function on read_timeout to terminate the job correctly

@tomas
Copy link
Owner

tomas commented Jul 20, 2017

Good catch! Would you add a quick test to ensure the PR fixes the bug?

@laittg
Copy link
Contributor Author

laittg commented Aug 9, 2017

A unit test is added, @tomas

$ mocha --grep 'follow redirects'


  follow redirects when read_timeout is set
    √ clear timeout before following redirect (3017ms)


  1 passing (3s)

@tomas
Copy link
Owner

tomas commented Aug 9, 2017

Beautiful! Thanks.

@tomas tomas merged commit 82d2493 into tomas:master Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants