-
Notifications
You must be signed in to change notification settings - Fork 165
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
fix(server/main): prevent multiple vehicle classes requests to client #572
Conversation
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.
Nice. Isn't each export invocation in a separate thread though? And yeah we should throw an error rather than return nil.
Yes, but why would that matter? The main problem is that the client can be overflowed with events because of the callbacks, in my case eventually kicking me out. Servers with low player counts would suffer, dev servers too where there's only 1 player. |
It should only ever make one callback though, then everything would be cached? How did you overload yourself? |
4b2fe51
to
26fdf8b
Compare
Mainly because the previous code did not correctly check if cache is available, and always assumed it isn't. Another problem spawns where say a first call to this function makes a callback, but while waiting for the client to answer, another call happens. The server is still waiting for the client to answer, but the second call already went through, making another callback. This isn't needed and is solved by creating a promise on the first call and awaiting it in the next calls. |
26fdf8b
to
f636ab2
Compare
Description
This fixes 3 issues:
nil
at first and checking for that.lib.callback.await
is async. This gives potential for multiple callbacks when vehicle classes aren't available, but are still being waited on by other callers. Fixed by creating a new promise, and resolving it when the callback is done.Might need more of a discussion on the 2nd point. What should happen if the client can't answer for some reason and the callback times out? Should we return
nil
like in the current solution or throw an error?Checklist