-
Notifications
You must be signed in to change notification settings - Fork 38
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 Socket.IO connection timeout #236
Conversation
… is always a `JS::Value` of type `JSVAL_TYPE_INT32`
…g `xhr.withCredentials` Socket.IO would die in the middle between `xhr.open` and `xhr.send`
Please add a description with a reference to the issue this PR closes Please add your posts regarding the issue from the python-monkey slack to the issue ticket so we have a clear reference and full activity log Please document why the fixes other than commit a001cca are needed as this was not discussed in the slack chat or in the issue ticket Also do we need to add a few tests at least no ensure no future regression? |
Would add standardized tests for XMLHttpRequest spec compliance in later PRs. |
Let's add that as a TODO new issue -> DONE #239 |
@Xmader please see how I documented the ticket for next time around |
Let's add the code so that the TODO tests described on line 40 and 41 of test_event_loop.py pass to this PR. for reference Let's indeed make sure to have a full suite of tests for setTimeout/clearTimeOut while we're at it |
FYI They were implemented in PythonMonkey/python/pythonmonkey/builtin_modules/timers.js Lines 39 to 41 in b1c3b6b
OK then we just needed to clean up the TODOs :-) |
Final question: why couldn't we use the XMLHttpRequest from dcp-xhr.js in dcp instead of coming up with our own? |
@philippedistributive Are you talking about https://gitlab.com/Distributed-Compute-Protocol/dcp/-/blob/develop/src/common/dcp-xhr.js?
SpiderMonkey engine itself doesn't provide any network abilities. We need to implement the |
Thanks it was a bit of a superficial, non-researched little inquiry indeed |
This PR fixes the following issues:
In XMLHttpRequest, previously we throw a
DOMException(InvalidAccessError)
when trying to access thexhr.withCredentials
getter/setter. However in socket.io-client, it tries to setxhr.withCredentials
but cannot catch the exception, thus breaks the connection.In our
clearTimeout
API, previously we expects thetimeoutId
argument is stored as an int32 value internally (JS numbers are always float64 values in JS context but mostly they are optimized internally). However in practice, JS number is not always optimized to an int32 value even though it's integral.In socket.io, old timers for the connection
timeout
don't get cancelled properly because thetimeoutId
seen as invalid, so the connection is closed prematurely.xhr.responseType
can be one of"" | "arraybuffer" | "blob" | "document" | "json" | "text"
. We implemented"text"
and"arraybuffer"
, but"json"
is missing, which socket.io also requires."blob"
or"document"
are still TODOs because there's no point outside of browser environment.This PR would close #232.