When using dependencies in the Serverless app, it might be really simple to install and use the NPM libraries. Troubleshooting it would seem simple too, as long as the mistake is human error.
It might also go wrong when the importing of the NPM library is not complete and troubleshooting it would be a nightmare.
What is the issue with it?
This problem cannot easily be reproduced in the local machine will have unlimited capacity of it's whole CPU capacity. It may not be the same in the cloud when Serverless app is run.
Every Serverless app comes with set CPU and RAM as it's capacity. Large NPM libraries might fails when it takes more time to import than the timeout of the function with its limited capacity.
- Any NPM libraries could fall victim to this. Mostly the libraries that are larger in size and larger dependencies on its own would fail to load within the timeout.
- It will be sporadic and may not fail always due to any external factor.
- The error it results in could be different every single time the function called where the dependency is used. It is due to the importing stage which might be different at different runs.
- So, importing larger dependencies is not reliable though it might succeed in the local testing and sometimes in the custom app.
How can this be found and fixed?
- The issue symptoms can be validated when NPM libraries are used.
- Troubleshooting may not be straightforward as the issue is sporadic.
- After the issue is found with an NPM library, alternative smaller NPM libraries can be used.
- Check the popularity, maintainability, weekly/monthly downloads to choose the dependencies to use for apps.
- If official NPM libraries of any service providers or popular and well-maintained NPM library is large in size and fails to import within timeout, request for Serverless app capacity increase for your application through our Assist portal.