Add error handling for async errors in client #2984
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2983 as well as adds an additional layer of error handling to the client top-level
run
function for errors thrown in eventemitter functions (that normally bypass therun().catch...
call).You can test the fix for #2983 by starting geth with default settings and then try to start our client with same defaults. You will observe an error message like
Server error - EADDRINUSE...
or something indicating that geth is already listening on port 30303.On master branch, once this error occurs, you will not be able to shut down the client using Ctrl + C because the client startup function hangs mid promise and never resolves. This handles the error gracefully and starts the client up. Oddly enough, the client seems to be able to use the port in contention and still be able to sync mainnet.
I also add some additional error handling for other (as yet unknown) errors thrown during async processes like
EventEmitter
events. This will log these errors and their stack trace to the console and then call the client shutdown function. If the client did not successfully start up and theclientStartPromise
has hung, it will ungracefully terminate the client after 30 seconds.