From e443c1bf46881900cf2712bcc558a23f070a7a5e Mon Sep 17 00:00:00 2001 From: Stephen Palmer Date: Sat, 15 Dec 2018 05:48:27 -0600 Subject: [PATCH 1/3] Bump version for new release; move to latest node patch release v8.14.0 --- .nvmrc | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.nvmrc b/.nvmrc index 368fe85..18e0a5e 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v8.12.0 +v8.14.0 diff --git a/package.json b/package.json index c7d17d0..de52f01 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "unity-cache-server", - "version": "6.2.0", + "version": "6.2.1", "description": "Unity Cache Server", "main": "lib/index.js", "engines": { - "node": "^8.12.0" + "node": "^8.14.0" }, "directories": { "test": "test" From 41be207a98ac930a1a28d65d934dd33fd5f25871 Mon Sep 17 00:00:00 2001 From: Stephen Palmer Date: Sat, 15 Dec 2018 06:04:04 -0600 Subject: [PATCH 2/3] Refactor test for stability --- test/protocol.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/protocol.js b/test/protocol.js index 33b9aa8..cf5ecd3 100644 --- a/test/protocol.js +++ b/test/protocol.js @@ -244,17 +244,15 @@ describe("Protocol", () => { resp.on('data', () => {}); client.pipe(resp); - const buf = Buffer.from(encodeCommand(cmd.getAsset, self.data.guid, self.data.hash), 'ascii'); - + let buf = Buffer.from([]); // queue up a bunch of GET requests to ensure there will be at least one open stream when we quit for(let i=0;i<100;i++) { - await new Promise(resolve => { - client.write(buf, () => resolve()); - }); + buf += encodeCommand(cmd.getAsset, self.data.guid, self.data.hash); } - // quit immediately - client.write(Buffer.from(encodeCommand(cmd.quit), 'ascii')); + client.write(Buffer.from(buf, 'ascii'), () => { + client.write(Buffer.from(encodeCommand(cmd.quit), 'ascii')); + }); return new Promise(resolve => { expectLog(client, /Destroying cache file readStream/i, resolve); From 9aadd3133b80bae74aaf9b3fae2218b904b214ac Mon Sep 17 00:00:00 2001 From: Stephen Palmer Date: Sat, 15 Dec 2018 06:15:08 -0600 Subject: [PATCH 3/3] Revert in favor a different approach --- lib/server/command_processor.js | 1 + test/protocol.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/server/command_processor.js b/lib/server/command_processor.js index 82c9ad1..7a101d8 100644 --- a/lib/server/command_processor.js +++ b/lib/server/command_processor.js @@ -25,6 +25,7 @@ class CommandProcessor extends Duplex { putStream: this._handleWrite.bind(this), command: this._handleCommand.bind(this), version: this._handleVersion.bind(this), + none: () => Promise.resolve() }; this._writeHandler = this._writeHandlers.version; diff --git a/test/protocol.js b/test/protocol.js index cf5ecd3..da00ea1 100644 --- a/test/protocol.js +++ b/test/protocol.js @@ -241,20 +241,24 @@ describe("Protocol", () => { it("should close file streams if the client drops before finished reading", async () => { const resp = new CacheServerResponseTransform(); - resp.on('data', () => {}); client.pipe(resp); - let buf = Buffer.from([]); + const buf = Buffer.from(encodeCommand(cmd.getAsset, self.data.guid, self.data.hash), 'ascii'); + // queue up a bunch of GET requests to ensure there will be at least one open stream when we quit for(let i=0;i<100;i++) { - buf += encodeCommand(cmd.getAsset, self.data.guid, self.data.hash); + await new Promise(resolve => { + client.write(buf, () => resolve()); + }); } - client.write(Buffer.from(buf, 'ascii'), () => { + // quit immediately + resp.on('header', () => { client.write(Buffer.from(encodeCommand(cmd.quit), 'ascii')); }); return new Promise(resolve => { + resp.on('data', () => {}); expectLog(client, /Destroying cache file readStream/i, resolve); }); });