-
Notifications
You must be signed in to change notification settings - Fork 105
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 "RangeError: Maximum call stack size exceeded" in hasBinary #109
base: master
Are you sure you want to change the base?
Conversation
Hi! Thanks for your work on this. I'm afraid of the increase of the package size in the browser, but we could release this under another package name (and provide it as a custom parser). What do you think? |
I seem to be having the issue this is fixing. |
flatted is 0.5kb gzipped - it wouldn't be a concern for me, but up to you as to how it's handled. It could potentially be broken out as two separate changes - handling circular JSON structures (which would be a custom parser) and "fixing the RangeError itself" (which would go into socket.io-parser) but I wasn't able to successfully separate the concerns on my first try. I'd rather try again to split them up into separate branches than make a custom parser which overrides bits and pieces of the existing one (I can see that being fairly messy) in order to both fix the RangeError and provide circular JSON support. @darrachequesne Any thoughts? |
A specially crafted packet could be incorrectly decoded. Example: ```js const decoder = new Decoder(); decoder.on("decoded", (packet) => { console.log(packet.data); // prints [ 'hello', [Function: splice] ] }) decoder.add('51-["hello",{"_placeholder":true,"num":"splice"}]'); decoder.add(Buffer.from("world")); ``` As usual, please remember not to trust user input.
zuul is now archived [1] and does not support the new W3C WebDriver protocol, since it relies on the wd package [2] under the hood, which uses the (now deprecated) JSON Wire Protocol. We will now use the webdriver.io test framework, which allows to run our tests in local and on Sauce Labs (cross-browser and mobile tests). This allows us to run our tests on latest versions of Android and iOS, since Sauce Labs only supports the W3C WebDriver protocol for these platforms ([3]). [1]: https://github.com/defunctzombie/zuul [2]: https://github.com/admc/wd [3]: https://docs.saucelabs.com/dev/w3c-webdriver-capabilities/
a333634
to
7a01357
Compare
Background
When piping a SerialPort instance to a socket.io
Socket
, the following occurs:Investigating further, I found this issue which was resolved by patching socket.io-parser like this. I cleaned up and modernized that patch for this repo. All credit to the original authors for their fix.
Changes
_deconstructPacket
hasBinary
Buffer
instances as binaryreconstructPacket
I tried to fix the RangeError without adding
flatted
, but it seems to be necessary as part of this solution. Hopefully the small additional dependency is worth the benefits in terms of preventing infinite recursion.