Function Run Time of 2 Seconds for CRM Cards is Horrendous
Hello
It seems like the serverless functions that power CRM Cards time out after 2 seconds. This is troubling as most calls to outside endpoints can take more than 2 seconds to initiate ask and return.
Even more troubling and frankly embarrasing, HubSpot can't even seem to handle its own examples being uploaded. I tried to install this example:
The serverless function 'crm-card' failed to execute: 2022-11-02T16:29:21.260Z 034b1579-846b-4018-bb3c-545c54751f5e Task timed out after 2.03 seconds.
Function logs
2022-11-02T16:29:21.260Z 034b1579-846b-4018-bb3c-545c54751f5e Task timed out after 2.03 seconds
So I think there's something inherently wrong with either the time limit being too conservative, or the way HubSpot is fetching and attempting to render these cards to the point where even a basic example isn't loading.
I think that you might be right about the fs module being the issue, I've imported it and used it many many times, and while you can import it and read files just fine, you obviously can't write out to the read only file system.
Function Run Time of 2 Seconds for CRM Cards is Horrendous
So investigated further. The 5s timeout increase did solve the timeout problem, but there was still an syntax error under the hood where it was failing if you used node12.
I wasn't sure if you or anyone was getting synax errors, but I did notice that in some of our own test projects. We've since updated all https://github.com/HubSpot/ui-extensions-examples examples to use node16, so as long as you're pulling in the latest examples, you should be good now.
Function Run Time of 2 Seconds for CRM Cards is Horrendous
Hi all. We just bumped up the timeout limit to 5 seconds. You'll need to rebuild/deploy again to pick up the changes as the timeout limits for our serverless are set at build time.
Function Run Time of 2 Seconds for CRM Cards is Horrendous
Hey @cconnors, In most development environments, there usually isn't a cap on runtime, HubSpot CMS doesn't limit website load time to 2 or 5 seconds (and it would be ludicrous if it did), old crm cards don't have this small of a timeout period. The load time has always been a thing that the developers need to watch and try to keep to a minimum, otherwise no one will want to use the app. The people using the app should be the ones deciding what the timeout period should be (because they are the ones in the end that will be negatively impacted) not hubspot. Just some thoughts, let us know what you think. I am really thankful for the 2.5 second increase though, thank you so much for that
Function Run Time of 2 Seconds for CRM Cards is Horrendous
HI @TL531. I can understand how this would be an issue. This is a beta and we're still trying to find the right balance between the developer and customer experience, while making sure our CRM Records load in a reasonable amount of time. I'm going to bring up with my team and come up with the best next steps here.
In the meantime, do you have examples of which API calls your making and how many in a serverless function? That should help us determine the best limits to put in place for the future.
Function Run Time of 2 Seconds for CRM Cards is Horrendous
So I wasn't even hitting any outside APIs; I was trying to run just the examples HubSpot provides (in this case, one that interacts with a form function) and that was timing out.
I think ideally if we could get 10 seconds for these that would work best, because most outside endpoints terminate in 5 seconds if no response given.
So I wasn't even hitting any outside APIs; I was trying to run just the examples HubSpot provides (in this case, one that interacts with a form function) and that was timing out.
That ideally shouldn't happen, so I will take it to the team for more investigation. My understanding was that you were hitting an outside endpoint by modifying the code sample. So, Thanks for clarifying.
Function Run Time of 2 Seconds for CRM Cards is Horrendous
Totally agree with Thomas on this one, is there any inherent reason why this isn't 10 seconds like the normal functions, besides client side load times (which has always been the job of the developer to keep efficient)? If we were able to trigger crm card functions via webhooks we could easily build workarounds for this.