refactor: Change Sync Functions to Promises to Prevent Blocking Event Loop (#896)

* initial commit

* lint

* lint 2
This commit is contained in:
vini
2024-07-03 04:29:16 -03:00
committed by GitHub
parent fdf9d48162
commit dbf25771a1
5 changed files with 21 additions and 15 deletions

View File

@@ -163,7 +163,7 @@ export const makeNoiseHandler = ({
return frame
},
decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => {
decodeFrame: async(newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => {
// the binary protocol uses its own framing mechanism
// on top of the WS frames
// so we get this data and separate out the frames
@@ -184,7 +184,7 @@ export const makeNoiseHandler = ({
if(isFinished) {
const result = decrypt(frame as Uint8Array)
frame = decodeBinaryNode(result)
frame = await decodeBinaryNode(result)
}
logger.trace({ msg: (frame as any)?.attrs?.id }, 'recv frame')