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

UnhandledPromiseRejectionWarning: browser disconnected. This problem may appear when a browser hangs or is closed, or due to network issues. #1814

Closed
gyopiazza opened this issue Sep 25, 2017 · 5 comments
Assignees
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@gyopiazza
Copy link

gyopiazza commented Sep 25, 2017

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

TestCafe randomly stops execution while running tests with this error:

(node:8659) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: The HeadlessChrome 0.0.0 / Mac OS X 10.12.5 browser disconnected. This problem may appear when a browser hangs or is closed, or due to network issues.
(node:8659) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Sometimes I also get this error:

(node:5426) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: First argument must be a string or Buffer

What is the expected behavior?

The tests should run (and pass or fail).

How would you reproduce the current behavior (if this is a bug)?

Try running many tests at once with some concurrency. I tried running them in many different combinations of concurrency and amount of tests but the errors still randomly appear.

Specify your

  • operating system: macOS 10.12.5
  • testcafe version: 0.17.2
  • node.js version: 8.4.0

As a sidenote, the error doesn't seem related with the moment problem as mentioned in other tickets, I also tried following the solution from #1769 but it didn't help. What else could I try? Thanks!

@AlexanderMoskovkin AlexanderMoskovkin added the TYPE: bug The described behavior is considered as wrong (bug). label Sep 25, 2017
@AndreyBelym
Copy link
Contributor

AndreyBelym commented Sep 25, 2017

Hello @gyopiazza!

How do you start TestCafe? It seems like you're using TestCafe API, do you? Could you provide a code that runs TestCafe please?

This error means that a browser stopped responding in the testing process. There is a lot of reasons why it can happen, so sharing your tests and the test page would be really helpful, can you afford this?

BTW, if we can't figure the actual reason why browsers hangs, at least we can restart the browser (#1815), or if it's concurrency mode, just we can just keep using another instances that stayed alive. I think it will be not so hard to implement it \cc @AlexanderMoskovkin

@gyopiazza
Copy link
Author

gyopiazza commented Sep 25, 2017

Hey @AndreyBelym!

Thanks for the fast response, and you guessed right, I'm using the TestCafe API. The tests are just simple click/type/waitFor actions which I don't think it's related to the problem because it happens randomly. Please let me know if an example of the tests I run could give you more hints and I'll share it too. This is how I instantiate TestCafe:

const tests = ['test1.js', 'test2.js' /*...*/];
createTestCafe('localhost', 9918, 9919)
        .then(tc => {
           const testcafe = tc;
           const runner = testcafe.createRunner();

           return runner
              .src(tests)
              .browsers('chrome:headless')
              .concurrency(10)
              .run({
                 skipJsErrors: true,
                 quarantineMode: true
               });
        })
        .then(failedCount => {
            console.log('Tests failed: ' + failedCount);
        })
        .catch(function(error) {
            throw(error);
        });

I expected the "quarantine" mode to take care of these situations but I guess it only kicks-in when the actual tests fail, and not for other errors. At first I thought it could be a "computer resources bottleneck" so I tried with a very low concurrency of 2 and even 1 (no concurrency) but the error still randomly appears. However, it didn't happen in the old version of TestCafe (>15.1.317053) but we could really benefit of the concurrency and other new features.

Your idea of restarting the browser or use another available instance sounds exactly what we need here. Basically when the browser is not responding TestCafe could kill the process and spawn a new one, without crashing the whole tests suite.

@AlexanderMoskovkin
Copy link
Contributor

@AndreyBelym, @gyopiazza I agree with you, the #1815 proposal looks good. I think we can do this in the next releases.

@AlexanderMoskovkin
Copy link
Contributor

closed in favor of #1815

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants