relay: only send if socket is open

This commit is contained in:
Alex Gleason 2023-08-25 15:00:48 -05:00
parent f7cd67c572
commit b60e84d29b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 3 additions and 2 deletions

View File

@ -1,5 +1,4 @@
import { AppController } from '@/app.ts'; import { AppController } from '@/app.ts';
import { type Event } from '@/deps.ts';
import { type DittoFilter } from '@/filter.ts'; import { type DittoFilter } from '@/filter.ts';
import { TOKEN_REGEX } from '@/middleware/auth19.ts'; import { TOKEN_REGEX } from '@/middleware/auth19.ts';
import { streamSchema, ws } from '@/stream.ts'; import { streamSchema, ws } from '@/stream.ts';

View File

@ -90,7 +90,9 @@ function connectStream(socket: WebSocket) {
/** Send a message back to the client. */ /** Send a message back to the client. */
function send(msg: RelayMsg): void { function send(msg: RelayMsg): void {
return socket.send(JSON.stringify(msg)); if (socket.readyState === WebSocket.OPEN) {
socket.send(JSON.stringify(msg));
}
} }
} }