Skip to content

Commit f6d18d3

Browse files
GuillaumeLagrangeart049
authored andcommitted
feat(core): throw when trying to call setupCore with no native core
1 parent a62c40d commit f6d18d3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

packages/core/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ export function getCodspeedRunnerMode(): CodSpeedRunnerMode {
3333
}
3434

3535
export const setupCore = () => {
36+
if (!native_core.isBound) {
37+
throw new Error(
38+
"Native core module is not bound, CodSpeed integration will not work properly"
39+
);
40+
}
41+
3642
native_core.InstrumentHooks.setIntegration("codspeed-node", __VERSION__);
3743
linuxPerf.start();
3844
checkV8Flags();

packages/core/tests/index.integ.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ describe("without bindings", () => {
2424
const isBound = require("..").isBound as boolean;
2525
expect(isBound).toBe(false);
2626
});
27+
28+
it("should throw when calling setupCore", () => {
29+
const setupCore = require("..").setupCore as () => unknown;
30+
expect(setupCore).toThrowError("Native core module is not bound");
31+
});
2732
});

0 commit comments

Comments
 (0)