Skip to content

Commit

Permalink
fix(stream): Start capturing incoming messages before stream is read (#…
Browse files Browse the repository at this point in the history
…76)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
gnarea and kodiakhq[bot] authored Jun 28, 2021
1 parent e509476 commit 3166702
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/MockWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ export class MockWebSocket extends EventEmitter {
callback(error);
},
read(_size: number): void {
connection.once('message', (message) => {
duplex.push(message);
});
// Do nothing. We're already recording incoming messages.
},
write(chunk: any, _encoding: string, callback: (error?: Error | null) => void): void {
connection.send(chunk);
callback();
},
});

this.on('message', (message) => duplex.push(message));

this.on('close', () => duplex.push(null));

this.on('error', (error) => duplex.destroy(error));
Expand Down

0 comments on commit 3166702

Please sign in to comment.