javascript-client icon indicating copy to clipboard operation
javascript-client copied to clipboard

Using Split within a Lambda that streams responses

Open roy2006 opened this issue 1 year ago • 2 comments
trafficstars

I'm using the Split nodejs SDK in my application. It's generally working fine, but I'm running into issues when using the SDK as part of a lambda that streams its response (as shown here). Specifically, the Lambda doesn't complete and just hangs until it times out.

The only thing I'm doing with Split is initializing it using the following code:

    const SplitFactory = require('@splitsoftware/splitio').SplitFactory;
    const SplitObj = await SplitFactory({
      core: {
            authorizationKey:splitAuthKey
      },
      startup: {
            readyTimeout :10
      },
      scheduler: {
            impressionsRefreshRate: 1,
            eventsPushRate: 2,
      }
    });

When this code is removed or if it's not executed, the lambda works as expected and finishes immediately after it's done streaming its output.

I'm using SDK version 10.25.1.

roy2006 avatar Mar 19 '24 13:03 roy2006

I just found out that calling client.destroy before exiting the handler allows the lambda to complete its operation as expected. However, this doesn't seem to be a viable option because it'll require me to initialize split with every lambda invocation.

roy2006 avatar Mar 19 '24 14:03 roy2006

Hi @roy2006 I believe you've worked this out in our Slack community and found a solution by setting _context.callbackWaitsForEmptyEventLoop = false

Could you confirm this issue is resolved?

agustinona avatar Mar 26 '24 19:03 agustinona