Revert to kill just the process for go-outline #3178
diff --git a/src/goOutline.ts b/src/goOutline.ts
index bdeda90..13aaafe 100644
--- a/src/goOutline.ts
+++ b/src/goOutline.ts
@@ -13,7 +13,7 @@
getFileArchive,
getGoConfig,
getToolsEnvVars,
- killTree,
+ killProcess,
makeMemoizedByteOffsetConverter
} from './util';
@@ -88,7 +88,7 @@
let p: cp.ChildProcess;
if (token) {
- token.onCancellationRequested(() => killTree(p.pid));
+ token.onCancellationRequested(() => killProcess(p));
}
// Spawn `go-outline` process
diff --git a/src/util.ts b/src/util.ts
index a5525ba..4254de7 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -860,6 +860,22 @@
});
};
+export function killProcess(p: cp.ChildProcess) {
+ if (p) {
+ try {
+ p.kill();
+ } catch (e) {
+ console.log('Error killing process: ' + e);
+ if (e && e.message && e.stack) {
+ const matches = e.stack.match(/(src.go[a-z,A-Z]+\.js)/g);
+ if (matches) {
+ sendTelemetryEventForKillingProcess(e.message, matches);
+ }
+ }
+ }
+ }
+}
+
export function makeMemoizedByteOffsetConverter(buffer: Buffer): (byteOffset: number) => number {
const defaultValue = new Node<number, number>(0, 0); // 0 bytes will always be 0 characters
const memo = new NearestNeighborDict(defaultValue, NearestNeighborDict.NUMERIC_DISTANCE_FUNCTION);