Open mavyfaby opened 1 month ago
I found a few problems with this issue:
cc: @cirospaciari
Note that Bun is not an officially-supported runtime, although it has been repeatedly requested and is on our radar: https://github.com/firebase/firebase-admin-node/issues/2572
Notably, grpc is known to not work on Bun. Some customers have reported success using the "preferRest" option:
const firestore = initializeFirestore(app, {
preferRest: true,
});
This causes the network stack to use simple HTTP requests when communicating with the backend, eliding grpc. Note, however, that "rest" does not support streaming, so adding a snapshot listener will try to "upgrade" the connection to grpc, which will likely result in the error that you reported. But as long as you don't need realtime updates, preferRest may help resolve your issue.
Unfortunatley, I cannot make any commitments as to a fix due to its lack of official support. If you find some low-hanging fruit in the https://github.com/googleapis/nodejs-firestore SDK then I'd be open to review a pull request.
Notably, grpc is known to not work on Bun. Some customers have reported success using the "preferRest" option:
In Bun v1.1.32, we added server support for our node:http2
implementation and pass almost all of Node.js' http2 tests. We also now run grpc-js's test suite on every commit and 95.25% pass. The failing tests are mostly related to http2 push or the http1 fallback.
Please let us know if you continue to run into issues with gRPC, Firebase, or Firestore in Bun (and file issues in our repo). If it works in Node and doesn't work in Bun, it is a bug in Bun.
In this particular issue's case, this appears to be a bundler bug (bun build --compile
runs the bundler). One thing you could try: bun build --compile --format=cjs <file>
. This will use CommonJS instead of ESM as the entry point, which might help here.
Hi @Jarred-Sumner! Thank you for chiming in and providing a suggestion. I'll admit, it's been a while since I tried Firestore with grpc in Bun, and I have very minimal experience with Bun. Again, the team's current priorities don't include Bun support, although I can say we've received a strong demand for it so it is on our radar.
Environment
v1.1.33
Linux 6.8.0-47-generic (Ubuntu)
firebase-admin@12.7.0
Firestore
Description
I'm using
firestore
and it works when usingbun src/index.ts
but not when using single executable file.and this happens when executing a firestore code, for instance this one:
and the error: