mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Merge branch 'fix-close' into 'main'
Fix relay always sending a CLOSED message after the client sends CLOSE See merge request soapbox-pub/ditto!730
This commit is contained in:
commit
b56fe678f2
2 changed files with 5 additions and 3 deletions
|
|
@ -165,6 +165,8 @@ function connectStream(socket: WebSocket, ip: string | undefined, opts: ConnectS
|
|||
|
||||
try {
|
||||
for await (const msg of relay.req(filters, { limit: 100, signal, timeout: conf.db.timeouts.relay })) {
|
||||
if (!controllers.has(subId)) break;
|
||||
|
||||
if (msg[0] === 'EVENT') {
|
||||
const [, , event] = msg;
|
||||
send(['EVENT', subId, purifyEvent(event)]);
|
||||
|
|
@ -186,8 +188,8 @@ function connectStream(socket: WebSocket, ip: string | undefined, opts: ConnectS
|
|||
send(['CLOSED', subId, 'error: something went wrong']);
|
||||
}
|
||||
} finally {
|
||||
controllers.get(subId)?.abort();
|
||||
controllers.delete(subId);
|
||||
controller.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ export class DittoPgStore extends NPostgres {
|
|||
|
||||
machina.push(['EOSE', subId]);
|
||||
}).catch((error) => {
|
||||
if (error instanceof Error && error.message.includes('timeout')) {
|
||||
if (error instanceof Error && (error.name === 'TimeoutError' || error.message.includes('timeout'))) {
|
||||
machina.push(['CLOSED', subId, 'error: the relay could not respond fast enough']);
|
||||
} else {
|
||||
machina.push(['CLOSED', subId, 'error: something went wrong']);
|
||||
|
|
@ -361,7 +361,7 @@ export class DittoPgStore extends NPostgres {
|
|||
yield msg;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.name === 'AbortError') {
|
||||
if (e instanceof Error && (e.name === 'TimeoutError' || e.message.includes('timeout'))) {
|
||||
yield ['CLOSED', subId, 'error: the relay could not respond fast enough'];
|
||||
} else {
|
||||
yield ['CLOSED', subId, 'error: something went wrong'];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue