title: My Lambda hangs when accessing LaunchDarkly through a middy wrapper
body: <p>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 <a href="https://docs.launchdarkly.com/guides/best-practices/serverless" rel="nofollow noreferrer">here</a>. That also is great.</p>
  <p>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.</p>
  <p>So this works:</p>
  <pre><code>const wrap = f =&gt; {
    return f;
    //   ...
  };   
  
    const clientLD = LaunchDarkly.init(process.env.LaunchDarklySDKKey, { logger });
  
   
    const handler = wrap(async (event,context) =&gt; {
    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;
  });
  </code></pre>
  <p>But this hangs:</p>
  <pre><code>const wrap = f =&gt; {
    return middy(f);
    //   ...
  };   
  
  // [same]
  </code></pre>