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

core: if the socket disconnects, reconnect with browser-login event with the new socket #1340

Merged
merged 1 commit into from May 11, 2019

Conversation

step2yeung
Copy link
Member

@step2yeung step2yeung commented May 9, 2019

core: if the socket disconnects, reconnect with browser-login event with the new socket

Scenario:
Sometimes, socketio disconnects. This emits a disconnect event, causing testem to call onDisconnect.
onDisconnect sets up a timeout with the value from browser_disconnect_timeout, which will always expire and report an Browser timeout exceeded: <x>s error. The disconnect timeout doesn't seem useful, since nothing is done in between.

Change:
Reconnect the browser socket. This improves the resilience from socket disconnecting.
eg. Help with issues like #1021

@step2yeung
Copy link
Member Author

@stefanpenner @johanneswuerbach would like to get your thoughts.

@stefanpenner
Copy link
Contributor

stefanpenner commented May 9, 2019

@step2yeung seems too good to be true, whats the catch?

@step2yeung
Copy link
Member Author

step2yeung commented May 10, 2019

@stefanpenner Great question.

Let me add a bit more context in what I believe this code change does:
When the socket disconnects, socketio by default auto reconnect. So from socketio side, it makes sure it does it's part. Testem currently ignores this reconnect.
By emitting the browser-login event during the reconnect, the browserTestRunner that represents the browser will setup the socket communication using the new socket.

One catch could be: disconnect has historically meant the browser is gone and cannot be communicated with anymore.
Now, disconnected is only a transient state, and connected state will return once reconnection is successful. This opens up the door for reconnection loop if the socket connection continues to drop.
To battle this, added browser_reconnect_limit that only allow x number of reconnections.

Sidenote: Additional anecdotical evidence for this fix. For several ember test suite that failed for Browser timeout exceeded where the socket disconnected, this change allowed the full test suite to run to completion.

@step2yeung step2yeung force-pushed the recon branch 2 times, most recently from 1055ec4 to fd23c6d Compare May 10, 2019 02:55
@stefanpenner
Copy link
Contributor

@step2yeung thank you for the explanation, that makes sense. Thank you also for adding the reconnect limit, that we we don't just get stuck reconnecting forever if something is seriously wrong.

This basically sounds to me more like testem bugfix then anything else, is that the right way for me to think about it?

Are there next steps for this?

@step2yeung
Copy link
Member Author

Yes, i believe that is a good way to look at this change. Where the bug is testem ignoring reconnects.
I do not see any next steps following this change.

@stefanpenner
Copy link
Contributor

@step2yeung should we release?

The appveyor test does need to be fixed, but it seems unrelated to this PR..

@step2yeung
Copy link
Member Author

@stefanpenner yes please! This should be release worthy.

Got #1335 started for the appveyor tests fixes

@raido
Copy link

raido commented May 10, 2019

I wonder if it helps with this: #1021 (comment) ?

@step2yeung
Copy link
Member Author

@raido I don't think this change helps with your issue. This helps fixes with socket disconnecting during the test execution.

If I understand your issue correctly, it looks like startup of tests does not even happen. So you should be getting Browser failed to connect within 30s, which means the testem server did not receive an event that tells it the browser is ready to run tests.

@raido
Copy link

raido commented May 11, 2019

You are correct. I get browser initial connection timeout. I have it set at 120s instead of default 30s but no help.

@stefanpenner stefanpenner merged commit 5e24ebe into testem:master May 11, 2019
@stefanpenner
Copy link
Contributor

released as v2.16.0 🎉

@raido
Copy link

raido commented May 11, 2019

How will it get into ember apps? Through internal dependency bump?

@step2yeung
Copy link
Member Author

@raido ember-cli depends on testem, so this will come with ember-cli
Its also possible to use the package.json resolution to point to the latest version

@raido
Copy link

raido commented May 15, 2019

I simply updated version in lock file.

@stefanpenner
Copy link
Contributor

re-rolling the lockfile should be sufficient.

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

3 participants