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

feat: set fetch timeout to 300 seconds #1386

Merged
merged 8 commits into from Apr 27, 2022
Merged

feat: set fetch timeout to 300 seconds #1386

merged 8 commits into from Apr 27, 2022

Conversation

kyrylkov
Copy link
Contributor

No description provided.

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Would be nice with a test.

@kyrylkov
Copy link
Contributor Author

kyrylkov commented Apr 27, 2022

@ronag Like no timeout for a request taking 60 seconds for example?

lib/fetch/index.js Outdated Show resolved Hide resolved
@ronag
Copy link
Member

ronag commented Apr 27, 2022

@ronag Like no timeout for a request taking 60 seconds for example?

Or a timeout for a request taking more than 300s. Look at out other test and how we handle timeout testing.

mcollina and others added 2 commits April 27, 2022 11:52
Co-authored-by: Michaël Zasso <targos@protonmail.com>
@kyrylkov
Copy link
Contributor Author

@ronag added tests

@kyrylkov kyrylkov changed the title Set fetch timeout to 300 seconds feat: set fetch timeout to 300 seconds Apr 27, 2022
test/node-fetch/main.js Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2022

Codecov Report

Merging #1386 (6390e7d) into main (8a8a20f) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1386   +/-   ##
=======================================
  Coverage   94.25%   94.25%           
=======================================
  Files          45       45           
  Lines        4211     4211           
=======================================
  Hits         3969     3969           
  Misses        242      242           
Impacted Files Coverage Δ
lib/fetch/index.js 80.89% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0608be8...6390e7d. Read the comment docs.

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you implement the tests using FakeTimers? See our other timeout tests.

@kyrylkov kyrylkov requested a review from targos April 27, 2022 11:09
@kyrylkov
Copy link
Contributor Author

kyrylkov commented Apr 27, 2022

@ronag I don't really know how to make it work. This naive doesn't work:

    if (p === '/timeout300s') {
      const clock = FakeTimers.install()
      clock.setTimeout(() => {
        res.statusCode = 200
        res.setHeader('Content-Type', 'text/plain')
        res.end('text')
      }, 300_000)
      clock.tick(300_000)
      clock.uninstall()
    }

@ronag
Copy link
Member

ronag commented Apr 27, 2022

@ronag I don't really know how to make it work. This naive doesn't work:

    if (p === '/timeout300s') {
      const clock = FakeTimers.install()
      clock.setTimeout(() => {
        res.statusCode = 200
        res.setHeader('Content-Type', 'text/plain')
        res.end('text')
      }, 300_000)
      clock.tick(300_000)
      clock.uninstall()
    }

No worries. Let's skip the test then and land this. Can you remove it?

@kyrylkov
Copy link
Contributor Author

I didn't commit FakeTimers. PR has tests with regular timers.

@ronag
Copy link
Member

ronag commented Apr 27, 2022

I didn't commit FakeTimers. PR has tests with regular timers.

Can you add { skip: true } to them then. Otherwise, it will take very long to complete the tests? That's why we want to use fake timers.

@kyrylkov
Copy link
Contributor Author

Done

test/node-fetch/main.js Outdated Show resolved Hide resolved
test/node-fetch/main.js Outdated Show resolved Hide resolved
@kyrylkov
Copy link
Contributor Author

kyrylkov commented Apr 27, 2022

@ronag It looks like your change is wrong. Fetch uses mocha which requires this.skip(), not an {skip: true} as argument

@kyrylkov
Copy link
Contributor Author

kyrylkov commented Apr 27, 2022

And that's the reason I cannot make FakeTimers work, cause fetch has different testing infrastructure

@kyrylkov
Copy link
Contributor Author

kyrylkov commented Apr 27, 2022

Here is the error I'm getting with 300 second timeout when using FakeTimers with setTimeout

image

@ronag ronag merged commit 2c41ce1 into nodejs:main Apr 27, 2022
KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
* Set fetch timeout to 300 seconds

* Update lib/fetch/index.js

Co-authored-by: Michaël Zasso <targos@protonmail.com>

* Add fetch timeout tests

* Fix formatting

* Skip fetch timeout tests

* skip tests

* fixup

* fixup

Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: Michaël Zasso <targos@protonmail.com>
Co-authored-by: Robert Nagy <ronagy@icloud.com>
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
* Set fetch timeout to 300 seconds

* Update lib/fetch/index.js

Co-authored-by: Michaël Zasso <targos@protonmail.com>

* Add fetch timeout tests

* Fix formatting

* Skip fetch timeout tests

* skip tests

* fixup

* fixup

Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: Michaël Zasso <targos@protonmail.com>
Co-authored-by: Robert Nagy <ronagy@icloud.com>
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
* Set fetch timeout to 300 seconds

* Update lib/fetch/index.js

Co-authored-by: Michaël Zasso <targos@protonmail.com>

* Add fetch timeout tests

* Fix formatting

* Skip fetch timeout tests

* skip tests

* fixup

* fixup

Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: Michaël Zasso <targos@protonmail.com>
Co-authored-by: Robert Nagy <ronagy@icloud.com>
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.

None yet

5 participants