-
Notifications
You must be signed in to change notification settings - Fork 1
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
Gracefully handle certain QUICSocket.send
errors
#86
Conversation
I think this stems from a design decision where data flowing downwards are normal function calls where data flowing upwards would be events. In this case it's making it inconvenient to bubble the send error where we need it. Consider the following. The The recv path takes a much cleaner flow through normal function calls. For our needs, it would be much simpler if the |
I want to maintain the design decision for now. To solve the #78 I think the proper solution is about distinguishing these kinds of errors. This is still doable with event/push flow. It's a matter of the the thing catching the exception and then deciding exactly what kind of event to dispatch. So instead of changing our control flow and data flow design, keep it the same and figure out how to distinguish 2 different event types. |
Remember push flow is inherently multi-consumer possible. So QUIC connections are all registered on the the socket events, but one can also register a specific kind of event type - if they all register to the same event type, they can further check the contents of the event to see if it is relevant to them. Generally it's more efficient to register unique event IDs - but this may not always be possible. |
Any design decisions on how events is going to work needs to take into the global consideration of MatrixAI/Polykey#444, and to add commentary there. |
We need to make sure our event abstractions and push flow abstraction makes sense in all our work. |
If we want to go the event route, then there are two things to do.
Since there are many connections to 1 socket, each connection will have to filter for the events only relevant to them. This means every active connection will have to do some processing for every error event filtering for the only one relevant to itself. I'm not sure I like that. Say we have 100 connections and the network cuts out, Now we have 100 sends failing. Each failed send will have an event being handled by all 100 connections trying to filter for what it wants. So we have 10000 if-checks happening. It's not going to scale very well. |
Firstly As for scaling the dispatch, there are ways to do this, lots of ways to achieve it, but the original dataflow/controlflow design should be maintained. |
Like I said, it's possible for lots of connections to register specific event IDs, thus enabling O(1) dispatch. |
The event names right now correspond to the to the name of the type. But I believe if you go to And this should lead you to understand how that might work seamlessly with observables. |
Okay, I'll look into it. |
And every importantly, the node specific warnings on event listener counts might need to be entirely eliminated, and instead what we do is manage the total counter of events in a global event bus system that keeps track of it, and can do a total warning if it detects resource leaks at a global level. |
|
That's kind of what |
I've got the fix down but just need to review and polish. I'm thinking I can do a fix for MatrixAI/Polykey-CLI#115 in this PR as well. At minimum I have the groundwork down for it. I just need to work out what errors happen when the internet drops out. |
Ultimately the solution was to create a new event for a send error that is coded with the connection ID of the connection so the connection can listen for the error event for it specifically. Right now it only this logic applies mostly to |
I think if we just ignore or do warnings about the following error then we can prevent crashes when the network cuts out.
|
I'm almost done with this. I'm just adding some tests to test network outages. Mainly mocking the udpsocket send to throw the same kind of error I posted in the above comment. The first test is working fine. But the 2nd where the connection times out when the sends is failing is working mostly. The only problem is the |
Error handling for push flows is inherently different from pull flows. Errors have to explicitly handled at the handler and possibly flow to a different global error handler. Don't rely on the error stack for push flows. |
657f032
to
e2c084b
Compare
I'm considering this one done now if you want to look it over. |
This commit addresses the send failures by taking any send specific errors and passing them back to the connection to be handled. Any errors such as bad arguments results in the connection throwing the problem proactivity. Any network failures are generally ignored and the Connections are left to time out. This allows for the network to drop for a short amount of time without failure of the connection and streams. [ci skip]
e2c084b
to
70df59c
Compare
Description
This PR attempts to fix the problem with socket send errors not being handled properly when they're specific to the connection triggering the send.
Issues Fixed
js-quic
hard crashes when bound to loopback and creating connection to an external address. #78Tasks
Final checklist