fix: possible leak on waitForMessage

This commit is contained in:
Adhiraj Singh
2021-11-25 19:51:49 +05:30
parent 1f8663092f
commit b91a1cbcf3

View File

@@ -123,12 +123,14 @@ export const makeSocket = ({
ws.on(`TAG:${msgId}`, onRecv)
ws.on('close', onErr) // if the socket closes, you'll never receive the message
ws.off('error', onErr)
},
)
return result as any
} finally {
ws.off(`TAG:${msgId}`, onRecv)
ws.off('close', onErr) // if the socket closes, you'll never receive the message
ws.off('error', onErr)
}
}
/** send a query, and wait for its response. auto-generates message ID if not provided */