Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
End the socket connections in a more graceful manner
Browse files Browse the repository at this point in the history
  • Loading branch information
Vektrat authored Apr 22, 2020
1 parent 7d242f4 commit 3338f6e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion catapult-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "catapult-sdk",
"version": "0.7.20.30",
"version": "0.7.20.31",
"description": "Catapult SDK core",
"main": "_build/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion rest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "catapult-api-rest",
"version": "1.0.20.30",
"version": "1.0.20.31",
"description": "",
"main": "_build/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions rest/src/connection/catapultConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = {

packetParser.onPacket(packet => {
connection.removeListener('close', innerReject);
connection.destroy();
connection.end();
resolve(packet);
});
});
Expand All @@ -78,7 +78,7 @@ module.exports = {
const timeout = new Promise((resolve, reject) => {
const id = setTimeout(() => {
clearTimeout(id);
connection.destroy();
connection.end();
rejectOnClose(reject)();
}, timeoutMs);
});
Expand Down
12 changes: 6 additions & 6 deletions rest/test/connection/catapultConnection_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const { expect } = require('chai');

describe('catapult connection', () => {
const createTestContext = () => {
let isDestroyed = false;
let isEnded = false;
const context = {
isDestroyed: () => isDestroyed,
isEnded: () => isEnded,
onCalls: {},
onceCalls: {},
writeCalls: [],
Expand All @@ -47,8 +47,8 @@ describe('catapult connection', () => {

emit: name => context.onCalls[name](),

destroy: () => {
isDestroyed = true;
end: () => {
isEnded = true;
}
}
};
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('catapult connection', () => {
});
expect(context.removeCalls).to.have.all.keys('close');
expect(context.removeCalls.close).to.equal(context.onceCalls.close);
expect(context.isDestroyed()).to.be.equal(true);
expect(context.isEnded()).to.be.equal(true);
});
});

Expand Down Expand Up @@ -173,7 +173,7 @@ describe('catapult connection', () => {
// Assert:
expect(err.statusCode).to.equal(503);
expect(err.message).to.equal('connection failed');
expect(context.isDestroyed()).to.be.equal(true);
expect(context.isEnded()).to.be.equal(true);
});
});

Expand Down

0 comments on commit 3338f6e

Please sign in to comment.