Skip to content
New issue

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

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

Already on GitHub? # to your account

Issues with .timeout() and network timeouts #393

Open
patrickisallen opened this issue Sep 7, 2017 · 4 comments
Open

Issues with .timeout() and network timeouts #393

patrickisallen opened this issue Sep 7, 2017 · 4 comments

Comments

@patrickisallen
Copy link

patrickisallen commented Sep 7, 2017

When trying to upload large files through the post method I get the following errors:

Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

This can be solved by adding a timeout to the it() block like so

it("should set timeout at the end of the block, function(done) {
}, 1000000)

but the second error that I cannot seem to remedy is

FetchError: network timeout at: http://exampleUploadURL.com

The upload continues and finishes eventually but the test continues to fail and I have not found a proper solution to wait for the upload to completely finish. This is not an issue for smaller files as it does not reach a timeout.

After further investigation the included .timeout() function and setting the timeout through .globalSetup() and .setup() is not working as intended. The sample code below results in this error

    Expected value to be (using ===):
      100
    Received:
      5000
    it("should configure timeout", function(done) {
        frisby.timeout(100)
        .use(function(spec) {
            expect(spec.timeout()).toBe(100);
        })
        .fetch(testHost +'/timeout' )
        .catch(function(err) {
            expect(err.name).toBe('FetchError');
        })
        .done(done);
    })
@patrickisallen patrickisallen changed the title FetchError: network timeout at {URL} Timeout Issues with .timeout() and network timeouts Sep 8, 2017
@patrickisallen patrickisallen changed the title Timeout Issues with .timeout() and network timeouts Issues with .timeout() and network timeouts Sep 11, 2017
@gdereese
Copy link

@patrickisallen, I am having the same issue. However, frisby 2.0.5 has a unit test with your exact code in it, which passes when I run it. At any rate, I still get the same FetchError even after bumping up the Jasmine timeout interval and applying timeout through the 3rd it() parameter, or by tacking on .timeout() to the frisby I'm building up.

@gdereese
Copy link

gdereese commented Sep 29, 2017

@patrickisallen I think I just worked out a solution. Like you stated, setting the timeout through the 3rd it() parameter overrides the jasmine.DEFAULT_TIMEOUT_INTERVAL, but you must also chain a .timeout() call in your frisby spec buildup in order to have the test honor the timeout:

it("should do something", function() {
  frisby
    .timeout(10000) 
    .get("url here");
}, 10000);

Also, note that the sequence of the timeout() call is important, as I've found that if you place it AFTER the get() call, in this case, the timeout is not set in time for the get() to fire; it must be placed BEFORE in order to work.

Hope this helps.

@patrickisallen
Copy link
Author

@gdereese I'll check it out! Thanks for looking into it. I've been blocked on this ever since I've posted.

@EasyZeng2018
Copy link

EasyZeng2018 commented Feb 12, 2018

@gdereese , that's a good way. It's a great walkaround for now.

My code is handling restful api using frisby like: frisby.get, frisby.post, frisby.put..., so it's not good for me to add timeout within the common method.
Hope the author can consider this issue to work out a wonderful solution. Thank you.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants