-
Notifications
You must be signed in to change notification settings - Fork 58
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
Change logic around closing connections and writers API-1283 #1417
Conversation
const err = new Error(); | ||
setUpWriteFailure(err); | ||
|
||
const resolver = deferredPromise(); | ||
writer.write(createMessageFromString('test'), resolver); | ||
resolver.promise.catch((err) => { | ||
expect(err).to.be.equal(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was strange, basically making 1 === 1 assertion. It does not work if I rename one of the variables because we were wraping (and still doing) the err in IOError. (in a defected way we pass error as message, fixed that as well.)
Codecov Report
@@ Coverage Diff @@
## master #1417 +/- ##
==========================================
- Coverage 93.27% 93.20% -0.08%
==========================================
Files 464 466 +2
Lines 16386 16623 +237
Branches 1333 1351 +18
==========================================
+ Hits 15284 15493 +209
- Misses 801 827 +26
- Partials 301 303 +2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
} | ||
for (const item of this.queue) { | ||
item.resolver.reject(this.error); | ||
item.resolver.reject(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is added but not covered, and this is normal. Actually there was no test before my change as well. I did not change the logic of here. Just added this.close() to the end of this function. I don't want to add a test for this because it is not trivial and requires some magic with sinon.
Note regarding coverage: The coverage drop is shown as 0.16% but I see that the drop is due to SSL tests because the drop is in Also note that codecov does not show a line that is added but not covered in this PR. (except a single line, I explained it above) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed all codes and tests, it seems good. I could not find any problem. I have only one question that I am not sure. After response I can approve.
…azelcast#1417)" This reverts commit 2d0b397.
…st#1417) The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that. - Moved socket closing responsibility to Writers - Fixed a test in PipelinedWriterTest - Ongoing and future socket.write calls will end with an error after the writer is closed. This is because close() destroys the socket and any ongoing and future socket.write calls will end with an error as described in node.js [documentation](https://nodejs.org/api/stream.html#writabledestroyerror). So we will be able to reject all deferred promises in the write queue upon close due to connection.close() or socket write error close(). - We were not closing the socket on write error before, now we do it. We were sending end packet and don't write anymore. This is the same as java. [See](https://hazelcast.slack.com/archives/C01JU7ZJYGP/p1668695419424179) fixes hazelcast#1256
…azelcast#1417)" (hazelcast#1430) This reverts commit 2d0b397.
…st#1417) The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that. - Moved socket closing responsibility to Writers - Fixed a test in PipelinedWriterTest - Ongoing and future socket.write calls will end with an error after the writer is closed. This is because close() destroys the socket and any ongoing and future socket.write calls will end with an error as described in node.js [documentation](https://nodejs.org/api/stream.html#writabledestroyerror). So we will be able to reject all deferred promises in the write queue upon close due to connection.close() or socket write error close(). - We were not closing the socket on write error before, now we do it. We were sending end packet and don't write anymore. This is the same as java. [See](https://hazelcast.slack.com/archives/C01JU7ZJYGP/p1668695419424179) fixes hazelcast#1256
…st#1417) The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that. - Moved socket closing responsibility to Writers - Fixed a test in PipelinedWriterTest - Ongoing and future socket.write calls will end with an error after the writer is closed. This is because close() destroys the socket and any ongoing and future socket.write calls will end with an error as described in node.js [documentation](https://nodejs.org/api/stream.html#writabledestroyerror). So we will be able to reject all deferred promises in the write queue upon close due to connection.close() or socket write error close(). - We were not closing the socket on write error before, now we do it. We were sending end packet and don't write anymore. This is the same as java. [See](https://hazelcast.slack.com/archives/C01JU7ZJYGP/p1668695419424179) fixes hazelcast#1256
…azelcast#1417)" (hazelcast#1430) This reverts commit 2d0b397.
…azelcast#1417)" (hazelcast#1430) This reverts commit 2d0b397.
…st#1417) The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that. - Moved socket closing responsibility to Writers - Fixed a test in PipelinedWriterTest - Ongoing and future socket.write calls will end with an error after the writer is closed. This is because close() destroys the socket and any ongoing and future socket.write calls will end with an error as described in node.js [documentation](https://nodejs.org/api/stream.html#writabledestroyerror). So we will be able to reject all deferred promises in the write queue upon close due to connection.close() or socket write error close(). - We were not closing the socket on write error before, now we do it. We were sending end packet and don't write anymore. This is the same as java. [See](https://hazelcast.slack.com/archives/C01JU7ZJYGP/p1668695419424179) fixes hazelcast#1256
…st#1417) The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that. - Moved socket closing responsibility to Writers - Fixed a test in PipelinedWriterTest - Ongoing and future socket.write calls will end with an error after the writer is closed. This is because close() destroys the socket and any ongoing and future socket.write calls will end with an error as described in node.js [documentation](https://nodejs.org/api/stream.html#writabledestroyerror). So we will be able to reject all deferred promises in the write queue upon close due to connection.close() or socket write error close(). - We were not closing the socket on write error before, now we do it. We were sending end packet and don't write anymore. This is the same as java. [See](https://hazelcast.slack.com/archives/C01JU7ZJYGP/p1668695419424179) fixes hazelcast#1256
…st#1417) The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that. - Moved socket closing responsibility to Writers - Fixed a test in PipelinedWriterTest - Ongoing and future socket.write calls will end with an error after the writer is closed. This is because close() destroys the socket and any ongoing and future socket.write calls will end with an error as described in node.js [documentation](https://nodejs.org/api/stream.html#writabledestroyerror). So we will be able to reject all deferred promises in the write queue upon close due to connection.close() or socket write error close(). - We were not closing the socket on write error before, now we do it. We were sending end packet and don't write anymore. This is the same as java. [See](https://hazelcast.slack.com/archives/C01JU7ZJYGP/p1668695419424179) fixes hazelcast#1256
…azelcast#1417)" (hazelcast#1430) This reverts commit 2d0b397.
…azelcast#1417)" (hazelcast#1430) This reverts commit 2d0b397.
…azelcast#1417)" (hazelcast#1430) This reverts commit 2d0b397.
…st#1417) The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that. - Moved socket closing responsibility to Writers - Fixed a test in PipelinedWriterTest - Ongoing and future socket.write calls will end with an error after the writer is closed. This is because close() destroys the socket and any ongoing and future socket.write calls will end with an error as described in node.js [documentation](https://nodejs.org/api/stream.html#writabledestroyerror). So we will be able to reject all deferred promises in the write queue upon close due to connection.close() or socket write error close(). - We were not closing the socket on write error before, now we do it. We were sending end packet and don't write anymore. This is the same as java. [See](https://hazelcast.slack.com/archives/C01JU7ZJYGP/p1668695419424179) fixes hazelcast#1256
…azelcast#1417)" (hazelcast#1430) This reverts commit 2d0b397.
…st#1417) The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that. - Moved socket closing responsibility to Writers - Fixed a test in PipelinedWriterTest - Ongoing and future socket.write calls will end with an error after the writer is closed. This is because close() destroys the socket and any ongoing and future socket.write calls will end with an error as described in node.js [documentation](https://nodejs.org/api/stream.html#writabledestroyerror). So we will be able to reject all deferred promises in the write queue upon close due to connection.close() or socket write error close(). - We were not closing the socket on write error before, now we do it. We were sending end packet and don't write anymore. This is the same as java. [See](https://hazelcast.slack.com/archives/C01JU7ZJYGP/p1668695419424179) fixes hazelcast#1256
…azelcast#1417)" (hazelcast#1430) This reverts commit 2d0b397.
fixes #1256
The issue was writing some data to the connection after it being closed. I changed and refactored some logic around PipelinedWriter and Connection to avoid that.