stripe-node icon indicating copy to clipboard operation
stripe-node copied to clipboard

Requests not aborted within timeout

Open conner-smith-anrok opened this issue 6 months ago • 5 comments
trafficstars

Describe the bug

I've noticed that the elapsed value in the Stripe.ResponseEvent sometimes exceeds the configured timeout by up to 15 seconds. I'm wondering if the request isn't being aborted within the timeout due to some bug in the timeout logic or if i'm misunderstanding how the timeout works

To Reproduce

Not deterministic, but the set-up is like this:

  • Initialize a Stripe client using a global timeout (e.g. 10 seconds)
  • Subscribe to Stripe.ResponseEvents. In the event handler, log elapsed field from each response event,
  • Send some requests over a period of time. Observe that the elapsed time for some requests exceeds the timeout

For perspective, we don't see this frequently. Over the past week, we've seen this in roughly 20 out of 10 million requests.

Expected behavior

Request aborted within the timeout or help me understand why the elapsed time is up to 15 seconds longer than the timeout

Code snippets

new Stripe(apiKey, {
    apiVersion: `2024-06-20`,
    stripeAccount: stripeAccountId,
    timeout: 10_000,
    maxNetworkRetries: 2,
});

stripe.on('response', (event: Stripe.ResponseEvent) => {
    console.log(`${event.elapsed}`); // sometimes as high as 25s
});

OS

linux

Node version

Node v22.14.0

Library version

stripe-node v16.7.0

API version

2024-06-20

Additional context

I can provide request IDs if that would be helpful, but this seems related to client-side code

conner-smith-anrok avatar May 06 '25 21:05 conner-smith-anrok