Skip to content

fix(node-sdk): await in-flight bulk requests when flushing on Lambda - #750

Draft
roncohen wants to merge 1 commit into
mainfrom
fix/node-sdk-lambda-flush
Draft

roncohen wants to merge 1 commit into
mainfrom
fix/node-sdk-lambda-flush

Conversation

@roncohen

Copy link
Copy Markdown
Contributor

Summary

  • Track and await already in-flight bulk deliveries during flush(), including timer-triggered and full batches.
  • Add regression coverage for overlapping batches and failed delivery.
  • Document Lambda use with ReflagClient, request-driven refresh, and awaited flushing in finally.
  • Add a SAM-deployable Lambda lifecycle probe using local SDK source, with delayed local HTTP and optional real-endpoint modes.
  • Include a Node SDK patch changeset.

Why

Previously, an automatic flush cleared the buffer before delivery completed. A subsequent explicit flush could return immediately, allowing Lambda to freeze with bulk I/O still pending. Workers use waitUntil; Lambda handlers must await flush before returning.

This fixes a demonstrated lifecycle race, but is not yet confirmation of the reported customer timeout root cause. Both ReflagClient and EdgeClient share the affected buffer.

Validation

  • Before rebasing onto current main: all 236 Node SDK tests passed; SDK build and strict probe type-check passed.
  • Local HTTP A/B probe: original SDK returned with one request pending in both timer/full modes; patched SDK returned with zero pending and one successful delivery.
  • git diff --check passes.
  • Post-rebase test rerun blocked by dependency installation: main upgraded Vitest; yarn install did not complete the fetch phase in this environment. CI should validate the current base.
  • Actual AWS deployment, warm/cold freeze-thaw testing, and real-endpoint latency measurements are still pending sandbox credentials/region.

Scope

No automatic Lambda detection, timeout increases, external queue, or extension. The documented pattern awaits flush on every invocation; delivery failures remain logged and discarded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant