7 hours ago
Some of my functions already deployed suddenly are throwing an error and crashing, in the logs I can see something like this:
NotImplementedError: node:v8 isBuildingSnapshot is not yet implemented in Bun.
I did not do any recent changes that could lead to this issue and is happening on some functions, not on all of them and is affecting multiple projects, please help ASAP with this
8 Replies
7 hours ago
This thread has been opened as a public bounty so the community can help solve it. The thread and any further activity are now visible to everyone.
Status changed to Open Railway • about 7 hours ago
7 hours ago
I have to put all my functions offline because of some logs and alerts do about this issue, please your help as soon as possible
6 hours ago
Good, this confirms what I suspected: node:v8's isBuildingSnapshot() and most of the V8-specific module is genuinely not implemented in Bun, with only writeHeapSnapshot and getHeapSnapshot supported. So this isn't a bug in your application code — it's a dependency somewhere in your stack calling into node:v8, and Bun throwing because that particular function isn't polyfilled.
The real question for "why did this start suddenly with no code changes on my end" is: what changed in the environment. A few likely culprits, roughly in order of probability:
Your hosting/serverless platform silently updated the Bun runtime version used to execute your functions (auto-updates, new default runtime, etc.), and the new version's compatibility shim either broke or a code path that previously avoided node:v8 is now hitting it.
A dependency (not your direct code) was auto-upgraded — e.g., a lockfile-less install, a ^/~ range resolving to a new minor/patch version, or a platform that rebuilds with latest tags — and the new version of that dependency added a call to node:v8 (frameworks, observability/tracing SDKs, and ORMs are common offenders here, since they sometimes use V8 heap/snapshot APIs for diagnostics).
A build cache invalidation caused some functions to be rebuilt with a different Bun/Node target while others (not yet redeployed/rebuilt) still run on the old runtime — explaining why it's "some functions, not all," even across multiple projects, if those projects share a platform or base image.
6 hours ago
Thanks for your answer, but looks like now all my serverless functions are failing as well, and throwing the same error, I suspect that this comes from some railway change or something similar. I'll wait for a appropriate response from Railway support team
6 hours ago
And looks like this is mostly related with mongo DB package:
at (/app/node_modules/mongodb/lib/bson.js:9:7)
at <anonymous> (/app/node_modules/mongodb/lib/admin.js:4:7)
at <anonymous> (/app/node_modules/mongodb/lib/index.js:6:7)2605 | this.PROCESS_UNIQUE = ByteUtils.randomBytes(5);
Bun v1.3.0 (Linux x64)
2606 | };
2607 | static {
2608 | this.resetState();
2609 | const { startupSnapshot } = globalThis?.process?.getBuiltinModule('v8') ?? {};
2610 | if (startupSnapshot?.isBuildingSnapshot()) {
^NotImplementedError: node:v8 isBuildingSnapshot is not yet implemented in Bun.
code: "ERR_NOT_IMPLEMENTED"
at <anonymous> (/app/node_modules/bson/lib/bson.cjs:2610:30)
at <anonymous> (/app/node_modules/bson/lib/bson.cjs:2597:1)6 hours ago
Getting this too.
calebjustice7
Getting this too.
2 hours ago
Hi @calebjustice7 after trying to fix this, looks like latest version of mongodb package 📦 7.3.0 have this issue with Bun runtime. So I suggest the a previous version of it, like 6.21.0 that works for me, you can set this version when import using the '@'. Here an example mongodb@6.21.0
2 hours ago
Formally acking
For anyone just joining us here, this isn't your code, it's a Bun compatibility gap. Railway Functions run on Bun, and the newer MongoDB driver (mongodb@7.3.0) pulls in a bson version that calls a V8 snapshot API (isBuildingSnapshot) that Bun doesn't implement yet, so it throws at import. A rebuild quietly bumped you onto that version, which is why it broke without any change on your end.
Pin back to a version that doesn't hit it:
mongodb@6.21.0
That drags in an older bson without the snapshot call, and your functions will deploy clean again.
Redeploy after pinning and you should be good.
We're tracking this so it stops catching people using MongoDB on Functions.
angelo-railway
Formally acking For anyone just joining us here, this isn't your code, it's a Bun compatibility gap. Railway Functions run on Bun, and the newer MongoDB driver (mongodb@7.3.0) pulls in a bson version that calls a V8 snapshot API (isBuildingSnapshot) that Bun doesn't implement yet, so it throws at import. A rebuild quietly bumped you onto that version, which is why it broke without any change on your end. Pin back to a version that doesn't hit it: `mongodb@6.21.0` That drags in an older bson without the snapshot call, and your functions will deploy clean again. Redeploy after pinning and you should be good. We're tracking this so it stops catching people using MongoDB on Functions.
31 minutes ago
Thanks, but looks like I already figure it out. Can I mark my own comment as the answer? hahaha I won the bounty 😂