# Netlify Function Timeout after 10 seconds when published

**URL:** <https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220>\
**Category:** Support\
**Tags:** lambda-functions\
**Created:** [July 5, 2020, 5:04pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220 "2020-07-05T17:04:36Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![chiubaca](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/chiubaca/32/4671_2.png) [@chiubaca](https://answers.netlify.com/u/chiubaca)\
**Post date:** [July 5, 2020, 5:04pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/1 "2020-07-05T17:04:36Z")

</div>

Hi Netlify Community!

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` .

What’s really weird is that I can see the output being returned correctly in the logs, it’s just the callback doesn’t complete correctly. My full code can be found on github here- [https://github.com/chiubaca/jottivity/blob/journals-crud/functions/get-journals.ts](https://github.com/chiubaca/jottivity/blob/journals-crud/functions/get-journals.ts)

Hope someone can assists! 😭🙏

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [July 6, 2020, 5:56am UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/2 "2020-07-06T05:56:08Z")

</div>

Hi, @chiubaca, to be clear our support team [doesn’t troubleshoot custom code](https://www.netlify.com/support-scope/#scope-limits) (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.

---

<div class="post-metadata">

**Author:** ![chiubaca](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/chiubaca/32/4671_2.png) [@chiubaca](https://answers.netlify.com/u/chiubaca)\
**Post date:** [July 6, 2020, 1:14pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/3 "2020-07-06T13:14:25Z")

</div>

Hi Luke, thanks for your reply,

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](https://github.com/firebase/snippets-node/blob/50df79b288b824b08e7e17c97415aa35c55d114f/firestore/main/index.js#L568-L572) . 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.

- [Using verifyIdToken()` with the second argument causes serverless function to timeout · Issue #929 · firebase/firebase-admin-node · GitHub](https://github.com/firebase/firebase-admin-node/issues/929)

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [July 6, 2020, 9:58pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/4 "2020-07-06T21:58:36Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![chiubaca](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/chiubaca/32/4671_2.png) [@chiubaca](https://answers.netlify.com/u/chiubaca)\
**Post date:** [July 7, 2020, 8:17am UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/5 "2020-07-07T08:17:26Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![tia](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@tia](https://answers.netlify.com/u/tia)\
**Post date:** [April 4, 2022, 7:59am UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/6 "2022-04-04T07:59:20Z")

</div>

why is netllify full of dumb problems like this

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [April 4, 2022, 7:30pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/7 "2022-04-04T19:30:09Z")

</div>

Hey there, @tia 👋

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?

---

<div class="post-metadata">

**Author:** ![BrinisGulf](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@BrinisGulf](https://answers.netlify.com/u/BrinisGulf)\
**Post date:** [March 13, 2023, 4:16pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/8 "2023-03-13T16:16:54Z")

</div>

I have this website b6ce2df3-b78a-4d99-8ae9-b39e44062672

I need to add timeout to more than 25 , something like 60 sec if possible

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [March 13, 2023, 4:21pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/9 "2023-03-13T16:21:45Z")

</div>

Hi @BrinisGulf we can’t do anything about 26s. This is a restriction set by AWS Lambda. Would you like me to bump you to 26s?

---

<div class="post-metadata">

**Author:** ![BrinisGulf](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@BrinisGulf](https://answers.netlify.com/u/BrinisGulf)\
**Post date:** [March 13, 2023, 4:23pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/10 "2023-03-13T16:23:48Z")

</div>

yes plz make it 26 sec if you can !

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [March 13, 2023, 4:24pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/11 "2023-03-13T16:24:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![BrinisGulf](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@BrinisGulf](https://answers.netlify.com/u/BrinisGulf)\
**Post date:** [March 13, 2023, 4:25pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/12 "2023-03-13T16:25:53Z")

</div>

make sense , when I use express is it the same ?

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [March 13, 2023, 5:28pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/13 "2023-03-13T17:28:47Z")

</div>

I’m not sure I understand what you mean by express. Can you clarify?

---

<div class="post-metadata">

**Author:** ![BrinisGulf](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@BrinisGulf](https://answers.netlify.com/u/BrinisGulf)\
**Post date:** [March 13, 2023, 5:44pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/14 "2023-03-13T17:44:26Z")

</div>

I mean nodejs express package in place of normal lambda function  
by using module.exports.handler = serverless(app);

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [March 14, 2023, 1:50pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/16 "2023-03-14T13:50:26Z")

</div>

Hi @BrinisGulf This workflow isn’t typical, please reference this: [How to run Express.js apps with Netlify Functions](https://www.netlify.com/blog/2018/09/13/how-to-run-express.js-apps-with-netlify-functions/)

---

<div class="post-metadata">

**Author:** ![davemof](https://avatars.discourse-cdn.com/v4/letter/d/edb3f5/32.png) [@davemof](https://answers.netlify.com/u/davemof)\
**Post date:** [June 6, 2023, 10:48am UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/17 "2023-06-06T10:48:42Z")

</div>

Could you bump our site e0c3dccf-54d1-4d5d-95b5-93580a90cc49 to 26s too please

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [June 6, 2023, 2:51pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/18 "2023-06-06T14:51:53Z")

</div>

> [@davemof](#):
>
> e0c3dccf-54d1-4d5d-95b5-93580a90cc49

Hi, thanks for reaching out! I’ve updated this for you! Please re-deploy to see this in effect.

---

<div class="post-metadata">

**Author:** ![davemof](https://avatars.discourse-cdn.com/v4/letter/d/edb3f5/32.png) [@davemof](https://answers.netlify.com/u/davemof)\
**Post date:** [June 6, 2023, 3:07pm UTC](https://answers.netlify.com/t/netlify-function-timeout-after-10-seconds-when-published/18220/19 "2023-06-06T15:07:49Z")

</div>

Thanks Sam. We are seeing really large latency when using external API’s (specifically [filemail.com](http://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.
