When using the `CallbackFunction` to define lambd...
# aws
e
When using the
CallbackFunction
to define lambdas, there is a major issue with the scoping. The generated code is exporting the entire callback
exports.handler = __f0
. While it should be fine, it leaves no room for us to open sockets/connection in the “global” lambda scope, but only in the invoked code which is a bad practice. Is there any way to solve this? Essentially, I want something like:
Copy code
exports.handle = __f0;

// Some connection code:
AWSLambda.init({...}) // sentry

function __f0(...) {
  // ...
}
For whomever falls into this pitfall, the answer is using the
callbackFactory
property instead of the
callback
one and make that callback return another callback