When the server sends a large number of logs for a long time, vscode does not respond or crashes for a short time. How can I modify the following code to solve this problem?
let reocrdEndData=""
class TestGetLog {
static createActiveDatalog(logger: LogOutputChannel, context:ExtensionContext): void {
const connect = createConnection({host: '127.0.0.1', post: 20001}, () => {
logger.show()
const sendPorts = [20001,20003]
if(connect.localPort && sendPorts.includes(connect.localPort)) {
connect.destroy()
TestGetLog.createActiveDatalog(logger,context)
}
})
connect.on('data', (data) => {
const logData = reocrdEndData + String(data)
const lines =logData.split('\n')
let rebuildData=""
if(logData.endsWith('\n')) {
reocrdEndData=""
rebuildData = lines.slice(0, lines.length -1).join('\n')
} else {
reocrdEndData = lines[lines.length -1]
rebuildData = lines.slice(0, lines.length -2).join('\n')
}
logger.info(rebuildData)
})
connect.on('close', () => {
connect.destroy()
})
}
}
Modify the following code to fix the crash or non-response problem, thanks