Importing NPM modules significantly impacts performance

I’ve noticed that function runtime can go from 200ms to 2.5s just by just importing modules into a function from a custom dependency.

An example is the firebase-admin module.

Then adding the single import line to an empty junction seems to have a severe impact on its performance

  const { initializeApp } = require('firebase-admin');

Are there any suggestions or work arounds to improve the performance?

Thank you

1 Like

Hey Tyler,
thank you for bringing this up, we’re actually actively working on making this initialization times more consistent across functions. We have some pending work that we hope to put in the upcoming release which should already mitigate this. There’s not really much you can do on your end at the moment but please let us know if you notice any other delay when using specific dependencies (especially firebase-admin since we added support for it not too long ago).

2 Likes