-
Notifications
You must be signed in to change notification settings - Fork 900
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
Calling Firebase function from Node.js results in FirebaseError: internal
#7636
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Turns out I was using Node.js 18 and it doesn't seem to be supported. Once I switched to Node.js 16, it started working. |
Actually the SDK is supposed to work in a Node 18 environment and if it doesn't, it's a bug. We do have separate Node and browser bundles for the functions package, and which one you get depends on the module resolution in your bundler config (e.g. mainFields or conditions). Do you know what your bundler config is? Are you using the default Next config? The difference between the two bundles is that the Node bundle polyfills fetch with |
@hsubox76 thanks for reopening this! It does indeed seem like a bug if that's the case. I'm running Next.js 13.4 and the code was failing on a React server component (which is running in Node). Literally changing Node from v18 to v16 (via Not sure I'm answering all your questions, but if there's anything else I can do to help triage this, I'm happy to help. |
May be related to #7280 but I don't think it's the same exact issue. This is a runtime error calling fetch and the other seems to be a compile-time error. |
I agree! I also ran into this issue by running the code in the description outside of Next.js, so this isn't Next related. |
I realized I completely missed that you were using the functions emulator. Do you still have this problem if you don't use the emulator, but a live function instead? It seems to have issues for me if using the emulator, with Node 18, but works fine live. Seems to be an emulators/Node 18 compatibility issue. I looked through the firebase-tools repo (the repo that includes the emulators runners) and I found this (related to the Firestore emulator, but it's similar, as it's making a http call): firebase/firebase-tools#5755 (comment) I tried it and I think it seems to work?
dns is a native node module so this should work fine in a plain node file but I'm not sure if you can use it in a React Server Component? Can you? If not, I think it might be worth adding a comment to that issue or creating a new one in the firebase-tools repo. |
@hsubox76 that's a great find! I'm not far enough in the project to even test the deployed functions, hence why I didn't catch this. Also, I just tried reverting to using Node.js v18 again and it now worked. I think it's because I'm using Not sure how you want to proceed with this, but I might be okay with it as it is for now, will just make a note that we need to set up the emulator host as If I encounter any other issues down the road I'll let you know. |
I don't think there's anything we can do on our end, emulators issues need to be resolved in firebase-tools. If you have any suggestions for that fix, you can add it in that issue (firebase/firebase-tools#5755 (comment)). I'll close this issue but thanks for the temporary workaround to explicitly use |
Sounds good! I've talked to Firebase support and they said the firebase-tools team will work on a fix. |
Operating System
macOS
Browser Version
Arc
Firebase SDK Version
10.4.0
Firebase SDK Product:
Functions
Describe your project's tooling
Next.js 13 (app router) with RSC.
The goal is to be able to call a firebase functions from both client and server components.
Describe the problem
I'm trying to setup a Next.js 13 (app router) application in a way that I could call a callable Firebase function from both client and server components.
When called from a client component (aka browser) everything seems to work fine.
However, when called from a server component (aka Node.js) I get an internal error with the code
functions/internal
.Steps and code to reproduce issue
In order to reproduce this issue, all you have to do is run the following code in Node.js:
You'd have to replace the environment variables with your own, as well as make sure the
helloWorld()
function is defined as a callable Firebase function:The text was updated successfully, but these errors were encountered: