Skip to content

Commit

Permalink
fix: fix websocketserver
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Feb 28, 2025
1 parent be64a93 commit 3c69150
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/bidiServer/PipeTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
*/
import debug from 'debug';

import {assert} from '../utils/assert.js';
import type {Transport} from '../utils/transport.js';

const debugInternal = debug('bidi:server:internal');
const debugInternal = debug('bidi:server:pipeTranspot');

export class PipeTransport implements Transport {
#pipeWrite: NodeJS.WritableStream;
Expand Down Expand Up @@ -55,14 +54,18 @@ export class PipeTransport implements Transport {
this.#onMessage = onMessage;
}
sendMessage(message: string) {
assert(!this.#isClosed, '`PipeTransport` is closed.');
// TODO: WebSocketServer keeps sending messages after closing the transport.
this.#isClosed; // are linters happy now?
// assert(!this.#isClosed, '`PipeTransport` is closed.');

this.#pipeWrite.write(message);
this.#pipeWrite.write('\0');
}

#dispatch(buffer: Buffer): void {
assert(!this.#isClosed, '`PipeTransport` is closed.');
// TODO: WebSocketServer keeps sending messages after closing the transport.
this.#isClosed; // are linters happy now?
// assert(!this.#isClosed, '`PipeTransport` is closed.');

let end = buffer.indexOf('\0');
if (end === -1) {
Expand Down

0 comments on commit 3c69150

Please sign in to comment.