firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

bun.sh grpc-js :: undefined is not an object (evaluating 'error.stack.split') :: what am I missing?

Open vincekruger opened this issue 1 year ago • 23 comments

[REQUIRED] Step 2: Describe your environment

  • Operating System version: macOS 13.5.2 (22G91)
  • Firebase SDK version: 11.10.1
  • Firebase Product: firestore
  • Node.js version: 18.17.1
  • NPM version: 8.19.2

[REQUIRED] Step 3: Describe the problem

I'm testing out bun and I can't do a basic get() on a collection. What am I missing?

Steps to reproduce:

index.ts

require('dotenv').config()

import { initializeApp } from 'firebase-admin/app'
initializeApp()
import { getFirestore } from 'firebase-admin/firestore'
export const db = getFirestore()
db.collection('category').get()

Run

bun index.ts

[0.05ms] ".env"
29 | const CALL_INVOCATION_TRANSFORMER_SYMBOL = Symbol();
30 | function isFunction(arg) {
31 |     return typeof arg === 'function';
32 | }
33 | function getErrorStackString(error) {
34 |     return error.stack.split('\n').slice(1).join('\n');
               ^
TypeError: undefined is not an object (evaluating 'error.stack.split')
      at getErrorStackString (/path/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:34:11)
      at onReceiveStatus (/path/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:356:40)
      at onReceiveStatus (/path/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:177)
      at /path/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/resolving-call.js:94:74
      at processTicksAndRejections (:1:2602)

vincekruger avatar Sep 09 '23 23:09 vincekruger

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Sep 09 '23 23:09 google-oss-bot

I got this issue as well

zRelux avatar Sep 11 '23 07:09 zRelux

I thought Bun wasn't going to work with grpc yet because of missing HTTP2 support?

Might be related to your issue.

Hope they support it soon though!

rubennaatje avatar Sep 11 '23 10:09 rubennaatje

I got the same issue. Thank goodness I googled the error since the stack trace didn't point to the line of code throwing the error.

antman786 avatar Sep 13 '23 04:09 antman786

I'm getting another bun error, not 100% sure if it's related: Import named 'firestore' not found in module '/***/node_modules/firebase-admin/lib/index.js'.

robertherber avatar Sep 13 '23 21:09 robertherber

I'm having this exact same issue as well when trying to use the @google-analytics/admin package just by doing a simple report await analyticsDataClient.runReport({...})

betoharres avatar Sep 14 '23 21:09 betoharres

Firebase Admin SDK requires a full Node.js runtime and currently not supported on other alternative JS environments.

lahirumaramba avatar Sep 15 '23 14:09 lahirumaramba

Firebase Admin SDK requires a full Node.js runtime and currently not supported on other alternative JS environments.

Yeah seems to me like this should be a bun.js issue and not here. They're the ones 'promising' full node compability.

rubennaatje avatar Sep 18 '23 09:09 rubennaatje

Agreed. There is a discussion ongoing there already regarding this. https://github.com/oven-sh/bun/issues/4746

vincekruger avatar Sep 18 '23 09:09 vincekruger

Ditto here... unable to use the firebase-admin SDK for firestore.

jontybrook avatar Oct 05 '23 20:10 jontybrook

I'd want to use bun.sh but not being able to use firebase-admin really is blocking

Daavidaviid avatar Oct 22 '23 14:10 Daavidaviid

Any ideas on when this might be fixed. I'm trying to use the Google Vision API but it seems like this is a problem with it to. This has totaly blocked the development of a big feature for us.

paulGeoghegan avatar Oct 25 '23 01:10 paulGeoghegan

Just because this is first on google, but please do checkout the discussion on bun's repo https://github.com/oven-sh/bun/issues/4746

TL;DR: Error.prototype.stack = ''; early in the program should fix this. (prevents the error but wont restore your stack trace, try-catch it yourself)

If you’re curious here is a nice rabbit hole to go down

samuelslva-jlfs avatar Oct 30 '23 14:10 samuelslva-jlfs

Things are improving (with improved http2/gRPC support in bun.sh 1.0.14) but firestore snapshots are still hanging.

ct-simon avatar Nov 25 '23 18:11 ct-simon

Still experiencing this issue using the google pubsub emulator on bun 1.0.15

Hagej avatar Dec 04 '23 14:12 Hagej

same for @google-cloud/firestore package, version 1.0.18

di-sukharev avatar Dec 20 '23 09:12 di-sukharev

Still seeing this on bun 1.0.25 and firebase-admin 12.0.0

e-simpson avatar Jan 25 '24 05:01 e-simpson

Trying to run a post build script after build on Vercel with command npx [email protected] run post.build.ts and still getting firestore/grpc/google-gax errors on bun 1.0.26:

Error posting version:  27 |  * @param status
28 |  */
29 | function callErrorFromStatus(status, callerStack) {
30 |     const message = **${status.code} ${constants_1.Status[status.code]}: ${status.details}`;
31 |     const error = new Error(message);
32 |     const stack = `${error.stack}\nfor call at\n${callerStack}`;
                                                                  ^
error: 4 DEADLINE_EXCEEDED: Deadline exceeded
 code: "4"
      at callErrorFromStatus (/vercel/path0/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/call.js:32:62)
      at onReceiveStatus (/vercel/path0/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:192:56)
      at onReceiveStatus (/vercel/path0/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)
      at onReceiveStatus (/vercel/path0/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
      at /vercel/path0/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/resolving-call.js:99:78
      at makeUnaryRequest (/vercel/path0/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:230:45)
      at /vercel/path0/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19
      at /vercel/path0/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
      at repeat (/vercel/path0/node_modules/google-gax/build/src/normalCalls/retries.js:79:81)
      at /vercel/path0/node_modules/google-gax/build/src/normalCalls/retries.js:118:13
      at call (/vercel/path0/node_modules/google-gax/build/src/call.js:67:27)
      at call (/vercel/path0/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19)
      at /vercel/path0/node_modules/google-gax/build/src/createApiCall.js:84:30
      at commit (/vercel/path0/node_modules/@google-cloud/firestore/build/src/write-batch.js:434:28)
      at set (/vercel/path0/node_modules/@google-cloud/firestore/build/src/reference.js:398:27)
      at module code (/vercel/path0/post.build.ts:30:8)

This occurs when calling the update or set member on a firebase-admin doc, example:

        firestoreAdminDoc.update({name: "value"});

e-simpson avatar Feb 04 '24 17:02 e-simpson

I am still not able to use firebase-admin (12.0.0) with bun (1.0.29).

SyntaxError: Export named 'initializeApp' not found in module '/Users/florianpurschel/Development/Projekte/server/node_modules/firebase-admin/lib/index.js'.

is that issue related to that or am I missing something here ?

puerschel93 avatar Feb 29 '24 18:02 puerschel93

same here!!!!!

nabildroid avatar Mar 03 '24 18:03 nabildroid

I'm facing the same issue. I was really hoping to switch from Node to Bun, but it's turned into a blocker for me. 😸

mouthzipper avatar Mar 16 '24 08:03 mouthzipper

try now to update your projects bun version to 1.1 bun update bun

melihsd avatar Apr 08 '24 13:04 melihsd

Can confirm firestore/grpc/google-gax errors are fixed for me on bun 1.1.2 ! 🎉

e-simpson avatar Apr 08 '24 16:04 e-simpson