JS Error from app - "Cannot find module 'lru-cache'"

Hi all, we are seeing this error triggered from an “afterCreate” JS file. This is triggered from the app side once it generates a particular row in our ‘AccidentReport’ table and the JS code is kicked off. This is the error: “Cannot find module ‘lru-cache’”. The JS developer is unsure as to why this error is being thrown.

Here is our app ID if needed:


This is the file that is being triggered that returns the error in the app:


Does anyone know what we can do to debug this further? Thanks in advance!

It looks to be a problem with your deployment.

Not all mailgun-js dependencies were deployed.

Please, try the following steps :

  1. Make sure you have all dependencies installed correctly locally.
    The node_modules/mailgun-js/node_modules/proxy-agent/node_modules/lru-cache folder should exist

  2. Deploy your code with --keep-zip command line parameter.

npm run deploy -- --keep-zip
  1. Make sure generated zip file (deploy.zip) contains node_modules/mailgun-js/node_modules/proxy-agent/node_modules/lru-cache folder


Also, FYI, whenever you want to perform an async operation in the event handler, that event handler must return a Promise wrapping that operation. See an example here
Otherwise, your business logic execution may be interrupted.

Thanks for the response, Vitaly! That makes sense. We will give this a try and let you know. I really appreciate the help on this!

Hi Vitaly, looks like that fixed the lru-cache issue, so thank you for that! The developer also made the suggested “Promise” wrapping to the code. However, we are now seeing an error:

“Custom business logic execution has been terminated because it did not complete in permitted time - 5 seconds”.

I’m sorry to ask, but we are a bit stumped on this - is it possible to take a quick look at the code to see what the issue could be, or what could cause that?


The error means the code takes more than 5 seconds to execute - which is a limit of the free tier of the product. We’d be happy to review your code and point out where it spends time, but that is not included in the free support. If you’d like to pay for it, please contact sales@backendless.com.



Your code doesn’t care about rejecting a promise whenever some error occurs.
In this case CodeRunner knows nothing about the error and still awaiting for a promise completeness until timeout

Thank you Vitaly, and good catch on that! We will attempt to fix that as well. I really appreciate you guys’ great support!