-
Notifications
You must be signed in to change notification settings - Fork 678
Add short delay when shutting event test server down #545
Conversation
// Give web3 a little time to close connection. | ||
setTimeout(function() { | ||
server.close(done); | ||
}, 150); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, zero isn't enough. Idk.
From your description it sounds like this could be a bug in the close logic. Once the Web3WsProvider's Anyway, it seems the reason our I've hacked together some changes in a branch (https://github.com/trufflesuite/ganache-core/tree/fix/websocket-close) and published a new temporary npm tag |
@davidmurdoch Thanks so much for looking into this. Really appreciate it. In my experiments with There's one caveat - at the moment Web3 treats Is that incorrect from your point of view? To get the tests to pass it was still necessary to call This is what things look like in Travis when running Web3's websocket rewrite within ganache's fix/websocket-close. (The messages are all logged from within Web3) Without disconnect(): fails
With disconnect(): succeeds
(Please close this at will - probably should have been an issue and not a PR). |
Thanks for following up so quickly!
All that to say: I do think you are right; I need to add the websocket close call on the web3 provider back in to our tests (and need to wait for it to finish closing) before calling our own Thanks again! Note: I'm about to hop on a plane and probably won't have time to test or update anything else for a few days. |
@davidmurdoch Sounds good. There's no urgency about this on Web3's side - was just investigating and trying to make sure the package will install for people correctly. Thanks again! (Am closing since there's a little more to this than a timeout). |
(Apologies in advance for the length of this explanation)
PR adds a short delay when shutting down the server in
test/event.js
.Background
I'm helping out at Web3.js. One of the project's goals is to improve stability by expanding its test suites. With that in mind, have added
ganache-core
's unit tests as an E2E which Web3 can sanity check its latest state against.Motive
In a PR which rewrites the WS provider to support auto-reconnect, am seeing a failure in a single event test, originating here.
https://github.com/trufflesuite/ganache-core/blob/9d50099b08e630650e11fe7ccfcf66cf5d9789bf/test/events.js#L63
It's a little mysterious but the TLDR is:
connection.close
is either being run non-sequentially for EventEmitter reasons or failing to complete because interrupted by the server close.Introducing a short delay before server shutdown allows disconnect to execute as expected.
By making this change, Web3 will (probably) install without test failures if you upgrade to a forth-coming patch version.