Fix: do not crash when IOStream._read() is called before socket is set #75
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found out that 'sometimes' _read() was called on IOStream before the socket wrapper was able to configure the socket.
Stacktrace:
I have implemented a test case where the stream is asked to read before the socket was set and now it doesn't crash anymore.
I do not think this is the fix and I am convinced that this problem is caused by something else but I do not know the library well enough to figure that out shortly.
Is it possible that this has todo because of promises being resolved within my listener on the wrapped socket when an upload is done?
My implementation (pseudo code):
The inputStream is listening for the 'end' event and resolves the promise created for that stream
Promise.all(streamPromises).then(....); handles some stuff and responds by emitting some event but 'sometimes' it fails by triggering the _read() on the IOStream as mentioned above.
If I missed something or made a mistake please let me know.