diff --git a/biome.jsonc b/biome.jsonc index fa3bb6ebb8..79609db0c9 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -28,6 +28,9 @@ "!packages/**/*/node_modules/" ] }, + "javascript": { + "globals": ["Bun"] + }, "linter": { "rules": { "correctness": { diff --git a/packages/beacon-node/package.json b/packages/beacon-node/package.json index aeb728da39..c7aa12d97b 100644 --- a/packages/beacon-node/package.json +++ b/packages/beacon-node/package.json @@ -51,6 +51,12 @@ "import": "./lib/util/index.js" } }, + "imports": { + "#prometheus-gc-stats-wrapper": { + "bun": "./lib/bun-wrappers/prometheus-gc-stats.js", + "default": "@chainsafe/prometheus-gc-stats" + } + }, "typesVersions": { "*": { "*": [ diff --git a/packages/beacon-node/src/bun-wrappers/prometheus-gc-stats.ts b/packages/beacon-node/src/bun-wrappers/prometheus-gc-stats.ts new file mode 100644 index 0000000000..59c2dd254e --- /dev/null +++ b/packages/beacon-node/src/bun-wrappers/prometheus-gc-stats.ts @@ -0,0 +1,7 @@ +// Bun does not support `GCProfiler` from `node:v8`a +// Which is exposed from `@chainsafe/prometheus-gc-stats` and used in `packages/beacon-node/src/metrics/nodeJsMetrics.ts` +// So we expose a dummy function for Bun runtime which do nothing for now +// TODO: May look get some useful data from `bun:jsc` +export function gcStats() { + return () => {}; +} diff --git a/packages/beacon-node/src/metrics/nodeJsMetrics.ts b/packages/beacon-node/src/metrics/nodeJsMetrics.ts index c448276e27..87c7c18e53 100644 --- a/packages/beacon-node/src/metrics/nodeJsMetrics.ts +++ b/packages/beacon-node/src/metrics/nodeJsMetrics.ts @@ -1,4 +1,4 @@ -import {gcStats} from "@chainsafe/prometheus-gc-stats"; +import {gcStats} from "#prometheus-gc-stats-wrapper"; import {Registry, collectDefaultMetrics} from "prom-client"; export function collectNodeJSMetrics(register: Registry, prefix?: string): () => void {