mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-09 01:17:06 +08:00
fix when kill child process, child process ANR - move the execution of pipeForRead.close() before the await statement.
This commit is contained in:
@@ -105,20 +105,17 @@ export function runAutoChatWithDaemon() {
|
|||||||
const pipeForReadWithJsonParser = pipeForRead.pipe(JSONStream.parse())
|
const pipeForReadWithJsonParser = pipeForRead.pipe(JSONStream.parse())
|
||||||
pipeForReadWithJsonParser?.on('data', async function waitForCanRun(data) {
|
pipeForReadWithJsonParser?.on('data', async function waitForCanRun(data) {
|
||||||
if (data.type === 'GEEK_AUTO_START_CHAT_CAN_BE_RUN') {
|
if (data.type === 'GEEK_AUTO_START_CHAT_CAN_BE_RUN') {
|
||||||
const ds = await initDb(getPublicDbFilePath())
|
|
||||||
|
|
||||||
const autoStartChatRunRecord = new AutoStartChatRunRecord()
|
|
||||||
autoStartChatRunRecord.date = new Date()
|
|
||||||
|
|
||||||
const autoStartChatRunRecordRepository = ds.getRepository(AutoStartChatRunRecord)
|
|
||||||
const result = await autoStartChatRunRecordRepository.save(autoStartChatRunRecord)
|
|
||||||
|
|
||||||
pipeForReadWithJsonParser.off('data', waitForCanRun)
|
pipeForReadWithJsonParser.off('data', waitForCanRun)
|
||||||
clearSuicideTimer()
|
clearSuicideTimer()
|
||||||
runWithDaemon({ runRecordId: result.id })
|
|
||||||
|
|
||||||
// if don't call close, when kill child process, child process will ANR.
|
// if don't call close, when kill child process, child process will ANR.
|
||||||
pipeForRead.close()
|
pipeForRead.close()
|
||||||
|
|
||||||
|
const ds = await initDb(getPublicDbFilePath())
|
||||||
|
const autoStartChatRunRecord = new AutoStartChatRunRecord()
|
||||||
|
autoStartChatRunRecord.date = new Date()
|
||||||
|
const autoStartChatRunRecordRepository = ds.getRepository(AutoStartChatRunRecord)
|
||||||
|
const result = await autoStartChatRunRecordRepository.save(autoStartChatRunRecord)
|
||||||
|
runWithDaemon({ runRecordId: result.id })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user