Skip to content
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

Remove race condition when server closes connection #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mathbruyen
Copy link

When server closes connection right after having sent some frames, those are ignored by the client. Frames are lost because they are processed in a nextTick/setImmediate callback, thus socket close event may arrive before they are actually processed.

Added a test that reproduces the error, on my computer it states that it received only 6 frames. I wonder if that could be computer-dependent so if that does not reproduce, try increasing to var count = 100; to something much larger.

The fix proposed here does not look right as it disables something done on purpose, as per the comment above (that's why I just commented out the line and not fixed the now useless bound method, I don't think this will be the real solution). Trying to delay socket end handling leads to socket errors, and I did not find anything better, so at least putting something that makes tests green. Welcome to any idea!

When server closes connection right after having sent some
frames, those are ignored by the client.

Frames are lost because they are processed in a
nextTick/setImmediate callback, thus socket close event
may arrive before they are actually processed.
@theturtle32
Copy link
Owner

Yes, this is a potentially challenging/sticky situation. I went back and forth on this a few times in the initial design/implementation of the library. It'll take some careful changes to implement this correctly.

@formula1
Copy link

formula1 commented Feb 25, 2022

Is this still an issue? At least the tests should get merged no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants