Skip to content

Commit 88b960a

Browse files
committed
fix(core): handle mongo terminate fail
1 parent a31ae7d commit 88b960a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/core/src/mongoMeasurement.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MongoTracer } from "./generated/openapi";
1+
import { ApiError, MongoTracer } from "./generated/openapi";
22

33
export class MongoMeasurement {
44
private tracerClient: MongoTracer | undefined;
@@ -42,7 +42,15 @@ export class MongoMeasurement {
4242

4343
public async terminate() {
4444
if (this.tracerClient !== undefined) {
45-
return await this.tracerClient.instrumentation.terminate();
45+
try {
46+
return await this.tracerClient.instrumentation.terminate();
47+
} catch (e) {
48+
// TODO handle terminate killing the server instead of returning a response first
49+
if (e instanceof ApiError) {
50+
console.error("Terminate failed with error");
51+
console.log(e.body);
52+
}
53+
}
4654
}
4755
}
4856
}

0 commit comments

Comments
 (0)