Skip to content

getHeapSnapshot causes lodestar beacon node to crash #23393

Open

Description

@twoeths

What version of Bun is running?

1.2.23

What platform is your computer?

Linux 5.15.0-119-generic x86_64 x86_64

What steps can reproduce the bug?

here's the api implemented in lodestar https://github.com/ChainSafe/lodestar/blob/f657221d882d8ce996d00dd873cfa79e8732218f/packages/beacon-node/src/util/profile.ts#L37

export async function writeHeapSnapshot(prefix: string, dirpath: string): Promise<string> {
  // Lazily import NodeJS only modules
  const fs = await import("node:fs");
  const v8 = await import("node:v8");
  const snapshotStream = v8.getHeapSnapshot();
  const filepath = `${dirpath}/${prefix}_${new Date().toISOString()}.heapsnapshot`;
  const fileStream = fs.createWriteStream(filepath);
  return new Promise<string>((resolve, reject) => {
    fileStream.on("error", (err) => {
      reject(err);
    });

    snapshotStream.pipe(fileStream);
    snapshotStream.on("end", () => {
      resolve(filepath);
    });
  });
}

note that I launched the node with ethereum hoodi public network so perhaps it requires more memory there
the api works fine if I launch a local small devnet on my localhost (Macbook)

What is the expected behavior?

no crash

What do you see instead?

oh no: Bun has crashed. This indicates a bug in Bun, not your code

Additional information

No response

Activity

  1. linear commented on Oct 9, 2025

    @linear
  2. twoeths commented on Oct 10, 2025

    @twoeths
    Author

    my beacon node running Bun was also crashed using generateHeapSnapshot() api

    export async function writeHeapSnapshot(prefix: string, dirpath: string): Promise<string> {
      const filepath = `${dirpath}/${prefix}_${new Date().toISOString()}.json`;
      const snapshot = Bun.generateHeapSnapshot("jsc");
      await Bun.write(filepath, JSON.stringify(snapshot, null, 2));
      return filepath;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnode:v8

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions