Skip to content

Commit

Permalink
send sigkill to symf when extension exits (#2225)
Browse files Browse the repository at this point in the history
Fix #1877
  • Loading branch information
beyang committed Dec 8, 2023
1 parent afdcb37 commit 977e19b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vscode/src/local-context/symf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class SymfRunner implements IndexedKeywordContextFetcher, vscode.Disposab
}

let wasCancelled = false
let onExit: (() => void) | undefined
try {
const proc = spawn(symfPath, ['--index-root', tmpIndexDir, 'add', scopeDir], {
env: {
Expand All @@ -282,6 +283,10 @@ export class SymfRunner implements IndexedKeywordContextFetcher, vscode.Disposab
stdio: ['ignore', 'ignore', 'ignore'],
timeout: 1000 * 60 * 10, // timeout in 10 minutes
})
onExit = () => {
proc.kill('SIGKILL')
}
process.on('exit', onExit)

if (cancellationToken.isCancellationRequested) {
wasCancelled = true
Expand Down Expand Up @@ -314,6 +319,9 @@ export class SymfRunner implements IndexedKeywordContextFetcher, vscode.Disposab
}
throw toSymfError(error)
} finally {
if (onExit) {
process.removeListener('exit', onExit)
}
disposeOnFinish.forEach(d => d.dispose())
await rm(tmpIndexDir, { recursive: true, force: true })
}
Expand Down

0 comments on commit 977e19b

Please sign in to comment.