Reputation: 85
We're using Middy as a wrapper with all our lambdas to deal with some logging and instrumentation logic, which is great. We also use LaunchDarkly (launchdarkly-node-server-sdk) to access feature flags serverlessly, following the basic option 1 proposed here. That also is great.
Now, trying to combine those approaches for a new lambda function dealing with stream events, I'm hitting an issue where the lambda gets invoked alright, but only once, and then hangs. When it times out, the invocation is deemed a failure and the event never removed from the stream, leading to new invocations every 120s on the same event forever. To be clear, it's not one of the decorations that is creating the issue, but it appears, middy itself.
So this works:
const wrap = f => {
return f;
// ...
};
const clientLD = LaunchDarkly.init(process.env.LaunchDarklySDKKey, { logger });
const handler = wrap(async (event,context) => {
try {
logger.info(event);
await clientLD.waitForInitialization();
const list = await clientLD.variation(
'tenants-forwarding-to-analytics',
{ key: 'lambda-function-dynamostreamforwarder' },
[],
);
logger.info(list);
} catch (e) {
logger.error(e.message, e);
}
return null;
});
But this hangs:
const wrap = f => {
return middy(f);
// ...
};
// [same]
Upvotes: 1
Views: 844