Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/misskey-dev/misskey into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
noridev committed Jun 9, 2023
2 parents d800b60 + 6182a1c commit 8df65eb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/backend/src/server/api/StreamingApiServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,23 @@ export class StreamingApiServerService {
if (userUpdateIntervalId) clearInterval(userUpdateIntervalId);
});

connection.on('message', async (data) => {
connection.on('pong', () => {
this.#connections.set(connection, Date.now());
if (data.toString() === 'ping') {
connection.send('pong');
}
});
});

// 一定期間通信が無いコネクションは実際には切断されている可能性があるため定期的にterminateする
this.#cleanConnectionsIntervalId = setInterval(() => {
const now = Date.now();
for (const [connection, lastActive] of this.#connections.entries()) {
if (now - lastActive > 1000 * 60 * 5) {
if (now - lastActive > 1000 * 60 * 2) {
connection.terminate();
this.#connections.delete(connection);
} else {
connection.ping();
}
}
}, 1000 * 60 * 5);
}, 1000 * 60);
}

@bindThis
Expand Down

1 comment on commit 8df65eb

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromatic detects changes. Please review the changes on Chromatic.

Please sign in to comment.