Skip to content

Commit b5c15ef

Browse files
committed
feat(core): report why the native core failed to bind
The require error was swallowed into a debug log, so a failed binding gave no clue whether the prebuild was missing, incompatible or broken. Carry the error to setupCore and include the runtime it was rejected for.
1 parent 864da3b commit b5c15ef

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎packages/core/src/index.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ export const setupCore = () => {
1616
warnOnUnsupportedNodeVersion();
1717

1818
if (!native_core.isBound) {
19+
const reason =
20+
native_core.bindError instanceof Error
21+
? native_core.bindError.message
22+
: String(native_core.bindError);
1923
throw new Error(
20-
"Native core module is not bound, CodSpeed integration will not work properly",
24+
`Native core module is not bound, CodSpeed integration will not work properly (Node ${process.version}, ABI ${process.versions.modules}, ${process.platform}-${process.arch}): ${reason}`,
2125
);
2226
}
2327

‎packages/core/src/native_core/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface NativeCore {
99

1010
interface NativeCoreWithBindingStatus extends NativeCore {
1111
isBound: boolean;
12+
bindError?: unknown;
1213
}
1314

1415
let native_core: NativeCoreWithBindingStatus;
@@ -76,6 +77,7 @@ try {
7677
MARKER_TYPE_BENCHMARK_END: 3,
7778
},
7879
isBound: false,
80+
bindError: e,
7981
};
8082
}
8183

0 commit comments

Comments
 (0)