Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Error] Firebase version compatibility problem in vercel (between 9.2.* -> 9.3.*) #5823

Closed
YongwoonJang opened this issue Dec 17, 2021 · 24 comments · Fixed by #5830
Closed

Comments

@YongwoonJang
Copy link

YongwoonJang commented Dec 17, 2021

Hello, Here is my bug report

  • Operating System version: macOS Big Sur 11.6.1
  • Browser version: Chrome Version 96.0.4664.110 (Official Build) (x86_64)
  • Firebase SDK version: 9.4.1
  • Firebase Product: storage

[REQUIRED] Describe the problem

Actually I use vercel and when I use "[email protected].* or @9.4." below error happens
But [email protected].
is good to operate.
below is error log

2021-12-17T16:30:40.729Z 7971a748-dd88-4c6e-973a-0d5c122617fc ERROR [2021-12-17T16:30:40.729Z] @firebase/firestore: Firestore (9.4.0): INTERNAL UNHANDLED ERROR: Error: ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto' at Object.openSync (fs.js:497:3) at Object.readFileSync (fs.js:393:35) at fetch (/var/task/node_modules/protobufjs/src/root.js:172:34) at Root.load (/var/task/node_modules/protobufjs/src/root.js:206:13) at Root.loadSync (/var/task/node_modules/protobufjs/src/root.js:247:17) at Object.loadProtosWithOptionsSync (/var/task/node_modules/@grpc/proto-loader/build/src/util.js:66:29) at Object.loadSync (/var/task/node_modules/@grpc/proto-loader/build/src/index.js:194:31) at loadProtos (/var/task/node_modules/@firebase/firestore/dist/index.node.cjs.js:14437:43) at newConnection (/var/task/node_modules/@firebase/firestore/dist/index.node.cjs.js:14459:20) at OnlineComponentProvider.createDatastore (/var/task/node_modules/@firebase/firestore/dist/index.node.cjs.js:18361:28) 2021-12-17T16:30:40.729Z 7971a748-dd88-4c6e-973a-0d5c122617fc ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'","reason":{"errorType":"Error","errorMessage":"ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'","code":"ENOENT","errno":-2,"syscall":"open","path":"/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto","stack":["Error: ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'"," at Object.openSync (fs.js:497:3)"," at Object.readFileSync (fs.js:393:35)"," at fetch (/var/task/node_modules/protobufjs/src/root.js:172:34)"," at Root.load (/var/task/node_modules/protobufjs/src/root.js:206:13)"," at Root.loadSync (/var/task/node_modules/protobufjs/src/root.js:247:17)"," at Object.loadProtosWithOptionsSync (/var/task/node_modules/@grpc/proto-loader/build/src/util.js:66:29)"," at Object.loadSync (/var/task/node_modules/@grpc/proto-loader/build/src/index.js:194:31)"," at loadProtos (/var/task/node_modules/@firebase/firestore/dist/index.node.cjs.js:14437:43)"," at newConnection (/var/task/node_modules/@firebase/firestore/dist/index.node.cjs.js:14459:20)"," at OnlineComponentProvider.createDatastore (/var/task/node_modules/@firebase/firestore/dist/index.node.cjs.js:18361:28)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:412:35)"," at processPromiseRejections (internal/process/promises.js:245:33)"," at processTicksAndRejections (internal/process/task_queues.js:96:32)"]} Unknown application error occurred

Steps to reproduce / Relevant Code:

This is my code which occurs an error.
When I test, error occurred between collection function call and getDocs function call

    const app = initializeApp(firebaseConfig);
    const db = getFirestore(app);
    const gyujanggakRef = collection(db, name);
    //Error is happened Here 
    const gyujanggakSnapshot = await getDocs(gyujanggakRef);

Thanks.

@jbalidiong
Copy link
Contributor

Hi @YongwoonJang, thanks for reporting this behavior. I tried replicating, but I wasn't able to reproduce the error. I verified that it's working fine for v9.3.*, v9.4.* and v9.6.1 SDKs. Would you mind trying to the update the SDK version that you're using and see if the issue persists?

@YongwoonJang
Copy link
Author

Hello thanks for your reply.

My build environment is Vercel(Next.js). (Vercel)[Vercel.com]

I inspect some change between "v9.2.* and v9.3.*"
and I find out that "firestore version of firesbase v9.2 and v9.3 is different"
firestore version for v9.2 is v3.2.0 and firestore version for v9.3 is v3.2.1.

and there is a change in " firestore > dist > index.node.cjs.js"
In v3.2.0's index.node.cjs.js line 14418 ~ 14421

// __filename and __dirname globals are unavailable in ES modules
// @ts-ignore To avoid using `--module es2020` flag.
const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.node.cjs.js', document.baseURI).href)));
const __dirname$1 = path.dirname(__filename$1);

but In v3.2.1's index.node.cjs.js above snippet is deleted.

and recent update 3.4.1 is below but it makes the same problem

// __filename and __dirname globals are unavailable in ES modules
// @ts-ignore To avoid using `--module es2020` flag.
const __filenameInESM = url.fileURLToPath(new (require('url').URL)('file:' + __filename).href);
const __dirnameInESM = path.dirname(__filenameInESM);

and I use firebase v9.6 and change firestore version 3.2.0 than issue is resolved.

So, I think that this skipped(or changed) snippet makes an error for Vercel framework.
My suggestion is check why that snippet is skipped.

Sincerely.
Thanks.

@schmidt-sebastian
Copy link
Contributor

Fix coming.

@michaldev
Copy link

I have this problem too on older versions like 9.1. How can I fix this problem now?

@schmidt-sebastian
Copy link
Contributor

You will have to upgrade to the new version once it has been released.

@michaldev
Copy link

I know. But I would like fix bug now.

@Darkbound
Copy link

Darkbound commented Dec 29, 2021

You will have to upgrade to the new version once it has been released.

Hey, I am having the same issue, and it only happens when the project is deployed on Vercel, my firebase version is 9.6.1.

Is that really a firebase problem or is it a Vercel problem, because if I build & start locally, its working fine.

P.S. I have the same error, just generated in a different way, for me it throws the error, when I try to fetch from getServerSideProps function.

2021-12-29T08:43:43.473Z ERROR	[2021-12-29T08:43:43.472Z]  @firebase/firestore: Firestore (9.6.1): INTERNAL UNHANDLED ERROR:  Error: ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'
    at Object.openSync (fs.js:497:3)
    at Object.readFileSync (fs.js:393:35)
    at fetch (/var/task/node_modules/protobufjs/src/root.js:172:34)
    at Root.load (/var/task/node_modules/protobufjs/src/root.js:206:13)
    at Root.loadSync (/var/task/node_modules/protobufjs/src/root.js:247:17)
    at Object.loadProtosWithOptionsSync (/var/task/node_modules/@grpc/proto-loader/build/src/util.js:66:29)
    at loadSync (/var/task/node_modules/@grpc/proto-loader/build/src/index.js:194:31)
    at loadProtos (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:14500:31)
    at newConnection (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:14522:20)
    at OnlineComponentProvider.createDatastore (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:18436:28)
2021-12-29T08:43:43.473Z	6baa3785-a25d-4ca6-9ac0-2632a7571206	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'","reason":{"errorType":"Error","errorMessage":"ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'","code":"ENOENT","errno":-2,"syscall":"open","path":"/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto","stack":["Error: ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'","    at Object.openSync (fs.js:497:3)","    at Object.readFileSync (fs.js:393:35)","    at fetch (/var/task/node_modules/protobufjs/src/root.js:172:34)","    at Root.load (/var/task/node_modules/protobufjs/src/root.js:206:13)","    at Root.loadSync (/var/task/node_modules/protobufjs/src/root.js:247:17)","    at Object.loadProtosWithOptionsSync (/var/task/node_modules/@grpc/proto-loader/build/src/util.js:66:29)","    at loadSync (/var/task/node_modules/@grpc/proto-loader/build/src/index.js:194:31)","    at loadProtos (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:14500:31)","    at newConnection (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:14522:20)","    at OnlineComponentProvider.createDatastore (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:18436:28)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open '/var/task/node_modules/@firebase/firestore/dist/src/protos/google/firestore/v1/firestore.proto'","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:412:35)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Unknown application error occurred

I am calling await getDoc(doc(firestore, "users", uid)) to fetch the user for a given user id, inside getServerSideProps, locally that works fine, it doesnt work when deployed on Vercel.

So do I too need to wait for that new version, and is there any place where I can check, what version I am waiting for and when is it supposed to go out?

@AppsusUK
Copy link

+1 on this issue getting the same error as @Darkbound when calling await getDoc in getServerSideProps on Vercel deployment, would appreciate any updates or temporary solutions until new version is released. This is causing huge issues when trying to push features to our production build.

@gholevas
Copy link

gholevas commented Dec 29, 2021

+1 getting the same error when deployed on both Vercel and Netlify. The production build locally works fine. Can confirm that downgrading to firebase 9.2 fixed the problem and allows it to work properly on both Vercel and Netlify.

@Darkbound
Copy link

@gholevas I just tried downgrading to 9.2.0 and now I am getting a different kind of error, that __dirname is undefined:

2021-12-30T08:15:28.163Z	2efabd03-8066-4964-a7e4-f6e3fcf73161	ERROR	[2021-12-30T08:15:28.163Z]  @firebase/firestore: Firestore (9.2.0): INTERNAL UNHANDLED ERROR:  ReferenceError: __dirname is not defined
    at loadProtos (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:14422:26)
    at newConnection (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:14446:20)
    at OnlineComponentProvider.createDatastore (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:18348:28)
    at OnlineComponentProvider.initialize (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:18333:31)
    at setOnlineComponentProvider (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:19198:35)
    at async ensureOnlineComponents (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:19214:9)
    at async getEventManager (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:19234:37)
    at async file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:19297:30
2021-12-30T08:15:28.164Z	2efabd03-8066-4964-a7e4-f6e3fcf73161	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"ReferenceError: __dirname is not defined","reason":{"errorType":"ReferenceError","errorMessage":"__dirname is not defined","stack":["ReferenceError: __dirname is not defined","    at loadProtos (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:14422:26)","    at newConnection (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:14446:20)","    at OnlineComponentProvider.createDatastore (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:18348:28)","    at OnlineComponentProvider.initialize (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:18333:31)","    at setOnlineComponentProvider (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:19198:35)","    at async ensureOnlineComponents (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:19214:9)","    at async getEventManager (file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:19234:37)","    at async file:///var/task/node_modules/@firebase/firestore/dist/index.node.mjs:19297:30"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: ReferenceError: __dirname is not defined","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:412:35)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Unknown application error occurred

@Darkbound
Copy link

I confirm that downgrading down to 9.1.0 works when deployed on vercel.

@hsubox76
Copy link
Contributor

hsubox76 commented Jan 4, 2022

I'm looking into this but if anyone who is more knowledgeable about Vercel has a quick answer, it may help: If the fix in @YongwoonJang 's comment above works (adding the conditional back), that seems to imply that document is defined in Vercel's deployed environment, and so it uses the second choice in the ternary. But the bundle Vercel is using is index.node.cjs.js which should be a Node only bundle for use in Node environments. Why is Vercel using code from Firebase's Node bundle in a browser environment?

There is a PR in process to add that conditional back, but the reason it was removed in the first place was because it broke Jest (see #5687) which has the opposite problem - because it uses jsdom, "document" does exist, which causes the ternary to take the wrong branch (the browser code) when it should be using the Node branch.

I'm trying to find a way to fix things for Vercel that does not break Jest again.

@hsubox76
Copy link
Contributor

hsubox76 commented Jan 5, 2022

Can anyone provide a minimal reproduction that I can work with to debug this?

@skwasan
Copy link

skwasan commented Jan 11, 2022

Getting same error. Whats solution?

@rodamaral
Copy link

Getting same error. Whats solution?

No new version has been published yet.

@schmidt-sebastian
Copy link
Contributor

We usually publish Thursdays.

@hsubox76
Copy link
Contributor

If anyone wants to test out a staging version with the fix, try [email protected] and let me know if it works. It should go without saying, do not use this version in production. If everything seems good, we are aiming to publish the production release tomorrow (Jan 13).

@kodai3
Copy link

kodai3 commented Jan 13, 2022

[email protected] works for me. Thank you !

@rodamaral
Copy link

Bumped from 9.0.1 to 9.6.3-20220130341 and it worked flawlessly. Thank you.

@YongwoonJang
Copy link
Author

It works for me. Thank you :)

@CRSylar
Copy link

CRSylar commented Jan 13, 2022

pushed 9.6.3-20220130341 from 9.6.1 on Vercel and now all Works great!

Thanks

@luyizhang
Copy link

9.6.3-20220130341 works. thanks! any update on production release yet?

@hsubox76
Copy link
Contributor

FYI just published 9.6.3 (release notes to come soon).

@Aitfakirali
Copy link

thank you so much I upgrade firebase to 9.6.3 and it worked

@firebase firebase locked and limited conversation to collaborators Feb 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.