question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Overwriting socket data / not waiting for a response

See original GitHub issue

Discovered this issue when working on a separate project that depends on TuyAPI.

(I believe this may be the root cause of https://github.com/codetheweb/tuyapi/issues/158 and https://github.com/codetheweb/tuyapi/issues/103.)

I added a condition to the data event handler for the socket that checks if the parsed and returned data is an object; if not it would throw an error. After adding this, tests started failing.

I discovered that on a fast enough machine (and testing against a local stub) it’s possible to overwrite data sent to the socket by calling .set() and/or .get() quickly after each other. Data has already been being overwritten in the test suite, but it wasn’t caught because I didn’t add a check to see if the returned data was an object or not.

For instance, running the test suite generated this beautiful packet:

000055aa000000000000000a000000607b226465764964223a223232333235313836646234613232313764633865222c2267774964223a223232333235313836646234613232313764633865222c22647073223a7b2231223a747275652c2232223a747275657d7d000000000000aa55000055aa000000000000000a000000617b226465764964223a223232333235313836646234613232313764633865222c2267774964223a223232333235313836646234613232313764633865222c22647073223a7b2231223a747275652c2232223a66616c73657d7d000000000000aa55000055aa000000000000000a000000617b226465764964223a223232333235313836646234613232313764633865222c2267774964223a223232333235313836646234613232313764633865222c22647073223a7b2231223a747275652c2232223a66616c73657d7d000000000000aa55

Obviously invalid. I took a stab at implementing a function queue system, but it’s not working.

Thoughts @tjfontaine @kueblc @unparagoned?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
codethewebcommented, Jun 1, 2019

@peterjuras it’s not quite ready yet; had some issues merging it last night and ran out of time to fix it. I’ll ping you when it’s published and ready. 😃

1reaction
codethewebcommented, May 31, 2019

PR that tentatively fixes it should be merged by the end of the week @peterjuras.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make JavaScript execution wait for socket.on function ...
You send a message and specify an ack callback. The receiver of the message then provides some ack data which your ack callback...
Read more >
Java Socket Programming - Socket Server, Client example
When you will run socket server, it will just print “Waiting for client request” and then wait for the client request. Now when...
Read more >
Going real time with Socket.IO, Node.Js, and React - Medium
With WebSockets, a client and a server will be able to talk to each other in real time, kind of like they were...
Read more >
WebSockets tutorial: How to go real-time with Node and React
The client sends out a request and keeps waiting for a response. ... are no longer an issue since data is served over...
Read more >
When TCP sockets refuse to die - The Cloudflare Blog
These sockets have no running timer by default - they will remain in that state forever, even if the communication is broken. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found