Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 9aadd31

Browse files
Revert in favor a different approach
1 parent 41be207 commit 9aadd31

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/server/command_processor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CommandProcessor extends Duplex {
2525
putStream: this._handleWrite.bind(this),
2626
command: this._handleCommand.bind(this),
2727
version: this._handleVersion.bind(this),
28+
none: () => Promise.resolve()
2829
};
2930

3031
this._writeHandler = this._writeHandlers.version;

test/protocol.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,24 @@ describe("Protocol", () => {
241241

242242
it("should close file streams if the client drops before finished reading", async () => {
243243
const resp = new CacheServerResponseTransform();
244-
resp.on('data', () => {});
245244
client.pipe(resp);
246245

247-
let buf = Buffer.from([]);
246+
const buf = Buffer.from(encodeCommand(cmd.getAsset, self.data.guid, self.data.hash), 'ascii');
247+
248248
// queue up a bunch of GET requests to ensure there will be at least one open stream when we quit
249249
for(let i=0;i<100;i++) {
250-
buf += encodeCommand(cmd.getAsset, self.data.guid, self.data.hash);
250+
await new Promise(resolve => {
251+
client.write(buf, () => resolve());
252+
});
251253
}
252254

253-
client.write(Buffer.from(buf, 'ascii'), () => {
255+
// quit immediately
256+
resp.on('header', () => {
254257
client.write(Buffer.from(encodeCommand(cmd.quit), 'ascii'));
255258
});
256259

257260
return new Promise(resolve => {
261+
resp.on('data', () => {});
258262
expectLog(client, /Destroying cache file readStream/i, resolve);
259263
});
260264
});

0 commit comments

Comments
 (0)