I’m trying to make a query to Firebase firestore with in a Netlify function which works perfectly fine when developing locally in Netlify dev, but when published I’m seeing the error:
2020-07-05T16:37:05.769Z 2ed6bae0-3702-441a-97b3-ad7cece3e9de Task timed out after 10.01 seconds .
Hi, @chiubaca, to be clear our support team doesn’t troubleshoot custom code (as a rule - never say never). So, we won’t be digging into the source code but other community members might.
With that said, I can explain the general case which is the most common root cause.
The cause of this is most often that some network connection isn’t being closed. The network connection being left open runs in the process itself being left running.
This often doesn’t cause issues in local testing but does in the deployed lambda function as it is required to exit in 10 seconds or less.
This is often resolved by changing the function code to include calls to close “the connection”. As far as what “the connection” actually is, it is typically a connection to an API or database.
To summarize, please check the code to confirm that you are closing all connections before returning. If that doesn’t resolve the issue or if there are other questions about this, please let us know.
I just need to figure out what “closing the connection” means in the context of firebase/ firestore. I’ve read through the docs a few times now and I believe I’m simply retrieving a “snapshot” of the data once using .get(). I cant seem to find any sort of methods which “close” the connection , no difference from this code snippet - snippets-node/index.js at 50df79b288b824b08e7e17c97415aa35c55d114f · firebase/snippets-node · GitHub . I will try to reach out to firebase support to see if i’ve missed anything.
UPDATE:
After troubleshooting with some friendly folks over on a Firebase slack channel, this issue is caused when attempting to verify a JWT using the firebase admin SDK. I’ve submitted the full details of this issue over on github here.
thanks for posting a link to that issue, @chiubaca! Seems like you are working with the firebase folks to figure out a solution - please do post it here when you find it so that others can learn from you. many thanks!
@perry Yes of course. Finally got to bottom of the issue!
To close the connection cleanly you have to call admin.app().delete(). Usually this is not necessary but seems to be important in the context of a Netlify function. Hope this help anybody else that stumbles across this.
Hillary from the Support team here. Sorry to hear you are encountering obstacles deploying your project. I imagine that this must be frustrating. Unfortunately, we can’t help you work towards a solution without more information about your site and the obstacle you are encountering. Can you please share a link to your Netlify site as well as a description of the error you are encountering?
Hi there! we can definitely bump you up to 26 seconds, but you’ll need to be on the Pro tier for us to make that change - that’s a requirement that applies to everyone who wants a bigger timeout. You can upgrade to Pro easily through the Netlify UI dashboard.
If you let us know when you have upgraded, we can change the settings for you!
Thanks Sam. We are seeing really large latency when using external API’s (specifically filemail.com). We don’t get that latency when using postman or localhost, we get a return within milliseconds. On Netlify this is above 10 seconds. Any help would be much appreciated.