UBERF-7197: Fix high cpu load (#5761)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-06-09 23:45:38 +07:00 committed by GitHub
parent 56c3f7ed02
commit 9f9fcd9963
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -14,6 +14,7 @@
// limitations under the License.
//
import { Analytics } from '@hcengineering/analytics'
import core, {
ClassifierKind,
DOMAIN_MODEL,
@ -74,7 +75,6 @@ import type {
TriggerControl
} from '../types'
import { SessionContextImpl, createBroadcastEvent } from '../utils'
import { Analytics } from '@hcengineering/analytics'
export class TServerStorage implements ServerStorage {
private readonly fulltext: FullTextIndex
@ -749,7 +749,7 @@ export class TServerStorage implements ServerStorage {
await this.broadcastCtx([{ derived: result }, ...applyCtx.derived])
})
}
setImmediate(() => {
setTimeout(() => {
void asyncTriggerProcessor()
})
}

View File

@ -412,11 +412,11 @@ function createWebsocketClientSocket (
ctx.measure('send-data', smsg.length)
await new Promise<void>((resolve, reject) => {
const doSend = (): void => {
if (ws.readyState !== ws.OPEN && !cs.isClosed) {
if (ws.readyState !== ws.OPEN || cs.isClosed) {
return
}
if (ws.bufferedAmount > 16 * 1024) {
setImmediate(doSend)
setTimeout(doSend)
return
}
ws.send(smsg, { binary: true, compress: compression }, (err) => {