Using serverless-offline-aws-eventbridge with express-async-errors throws error

Hi,

I have developed an API using the serverless framework, nodejs and express. To allow for a-synchronous error handling, I use express-async-errors.

However, as soon as I enable the serverless-offline-aws-eventbridge plugin and run offline, behaviour starts to go weird; once It throws one error just fine. But after one error, the following request (happy or error) throws an error and crashes sls offline like this:

TypeError: Cannot redefine property: handle
    at Function.defineProperty (<anonymous>)
    at Object.<anonymous> (/Users/frank/Code/waitless/waitless-api/services/orders/node_modules/express-async-errors/index.js:36:8)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/Users/frank/Code/waitless/waitless-api/services/orders/.build/src/app.js:19:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at /Users/frank/Code/waitless/waitless-api/services/orders/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:145:133
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at InProcessRunner.run (/Users/frank/Code/waitless/waitless-api/services/orders/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:145:9)

Any idea what may be causing this? And how I can prevent this from happening? I had similar experiences earlier with the serverless-offline-sns. Currently, I restart my sls offline from time to time when developing locally, but its kind of a pain. Or if anybody knows a better way to throw a javascript async i’m open to that as well.

Thank you, Frank

didn’t solve the issue but did fix the problem. Using express-async-handler now instead to wrap my express functions. Works like a charm.