-
Notifications
You must be signed in to change notification settings - Fork 66
Functions fail when using Firebase Admin SDK #68
Comments
hey @kristapsPelna ! saw you post on a thread on our community forum. sorry you're experiencing these issues! this is the first i'm learning of firebase <-> netlify functions issues, and another person just opened a firebase issue here on next-on-netlify yesterday as well. as i asked them: did you happen to see this thread/solution? https://community.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/5 let me know if that happens to help. |
@lindsaylevine Thanks for the reply, but unfortunately that is a different issue. In my situation the function fails with an error mentioned above and doesnt even reach the end of the function where I would be able to call |
This is a test function that I've been using.
|
Hey @kristapsPelna, thanks for posting your function code! That's super helpful. I created a minimal repo to reproduce the issue: https://github.com/FinnWoelm/next-on-netlify-firebase Here is my API endpoint with Cloud Firestore: https://github.com/FinnWoelm/next-on-netlify-firebase/blob/main/pages/api/test.js The issue // next.config.js
module.exports = {
target: "experimental-serverless-trace",
}; Longer explanation here (the Q focuses on Prisma, but it's the same issue of bundling binaries): #55 (comment) Can you try that and let us know if that resolves your issue? 😊 |
Hey @FinnWoelm, Thanks for the suggestion! |
Hi @kristapsPelna, Hmm... There is a 64MB limit for each Netlify Function (imposed by AWS Lambda). I don't think this is related to API endpoint using firebase-admin that you shared above (since that works here: https://github.com/FinnWoelm/next-on-netlify-firebase/blob/main/pages/api/test.js). The two functions took 50 seconds to package ( Is it possible that you have a Next.js page that is bundling a lot of dependencies? I'd be happy to take a look at your code, if it's open. Or, if you prefer to reproduce the issue in a minimal repo, I'd be happy to look at it, too. You can bundle your functions locally to see which function is exceeding the size (and even inspect the dependencies that are being bundled):
Be patient while your functions are analyzed and bundled with the required node modules. When done, you can open the zipped_functions directory and see the file sizes of the .zip archives. If you see one with 64MB+ size, that's the one to investigate further. By the way, I also noticed that my zip archives were smalled when switching from Next v10 to Next v9.5. Next v10 uses a dependency called Hopefully we can narrow in on the issue! 😊 |
@FinnWoelm Thanks for the reply. P.S. I tried the same project on Vercel and it builds and runs just fine. |
@lindsaylevine , thanks for quick feedback, with It seems that Next latest version has large bundle builds and hope you will work on it and optimize |
hey all! i'm going to close this issue in favor of #120, which groups several please feel free to re-open this issue if you think #120 does not suffice or if there's a specific piece separate from experimental-serverless-trace that still needs addressing. |
Hesitant to reopen this, because I'm not sure I have enough context to say that this issue hasn't been solved—however, I tracked with #120 which was updated as closed, and mention of it being released into the build system—but I'm still getting the error in this issue, and can't seem to figure out if there has been a solve. Any solutions other than downgrading Next to 9.5 at the moment? Or working for anyone else? |
@jaobrown which error exactly are you getting? there are a few different mentioned in here 😅 |
@lindsaylevine Whoops! Sorry about that. The OP's error—more specifically, mine is verbatim:
|
@jaobrown oh! have you changed your target in your next.config.js to
|
Functions fail when using Firebase Admin SDK.
When I am requesting data from firestore using firebase admin SDK, I get this error:
(node:14684) Warning: protos.json not found in any of the include paths \protos,\protos
(Use
node --trace-warnings ...
to show where the warning was created)Error: ENOENT: no such file or directory, open 'protos.json'
at Object.openSync (fs.js:466:3)
at Object.readFileSync (fs.js:369:35)
Can this be fixed?
Currently the admin SDK is not usable on the functions and getServerSideProps
P.S. Locally works just fine when running
next dev
but fails when runningnext build && next start
The text was updated successfully, but these errors were encountered: