#manish_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1243534595966631937
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- manish_api, 1 day ago, 26 messages
- manish_api, 2 days ago, 4 messages
Hi
the subsequent requests returns the last response instead of throwing an error
The requestId you've shared did return an error with http status 409
yea i can see that in logs, but it does not goes to the catch block in my code, it will just return the last successfull response
Have you had the chance to debug your code or add some log line ?
like log the requestId and the corresponding response status for example
yea i tried
even i tried with the sample in your doc https://docs.stripe.com/api/errors/handling
You are seeing two lines with different requestId and same http status ?
yea i tried
Can you then share the two requestId and what was the response status your sdk displayed ?
the sdk returned this
{
id: 'cus_QAHK8vmxDMWMaZ',
object: 'customer',
address: null,
balance: 0,
created: 1716551921,
currency: null,
default_source: null,
delinquent: false,
description: null,
discount: null,
email: null,
invoice_prefix: '341C5499',
invoice_settings: {
custom_fields: null,
default_payment_method: null,
footer: null,
rendering_options: null
},
livemode: false,
metadata: {},
name: 'Hopstack 1',
next_invoice_sequence: 1,
phone: null,
preferred_locales: [],
shipping: null,
tax_exempt: 'none',
test_clock: null
}
THEN BLOCK
{
id: 'cus_QAHK8vmxDMWMaZ',
object: 'customer',
address: null,
balance: 0,
created: 1716551921,
currency: null,
default_source: null,
delinquent: false,
description: null,
discount: null,
email: null,
invoice_prefix: '341C5499',
invoice_settings: {
custom_fields: null,
default_payment_method: null,
footer: null,
rendering_options: null
},
livemode: false,
metadata: {},
name: 'Hopstack 1',
next_invoice_sequence: 1,
phone: null,
preferred_locales: [],
shipping: null,
tax_exempt: 'none',
test_clock: null
}
couldnt find the requestId in its response
You need to inspect the header of the http response
From where you got this requestId req_QzRkODbWMHMEZk ?
from dashboard logs
How many requests you are sending during your test ?
while testing the indempotency i sent only two
Ok, I see that there were 3 requests actually with the same timestamp
in dashboard logs it shows it has returned error, but sdk is not rejecting the promise
if you want i can again send 2 requests
First one: req_Hk1z7GH1cnyORI
Second: req_QzRkODbWMHMEZk (with the error)
Third: req_ySRwboA8NBt4EP responded correctly which prints the correct result
if you want i can again send 2 requests
Yes please send just 2 other requests with a new idempotency key
and let me know to re-check
okay give me 2 minutes
successfull: req_XdHxuSQe2f8GCe
Failed: req_kXJNGuAnaAlGTc
SDK response
{
id: 'cus_QAHcWj2W68oddo',
object: 'customer',
address: null,
balance: 0,
created: 1716553023,
currency: null,
default_source: null,
delinquent: false,
description: null,
discount: null,
email: null,
invoice_prefix: '0BFDF721',
invoice_settings: {
custom_fields: null,
default_payment_method: null,
footer: null,
rendering_options: null
},
livemode: false,
metadata: {},
name: 'Test with stripe',
next_invoice_sequence: 1,
phone: null,
preferred_locales: [],
shipping: null,
tax_exempt: 'none',
test_clock: null
}
{
id: 'cus_QAHcWj2W68oddo',
object: 'customer',
address: null,
balance: 0,
created: 1716553023,
currency: null,
default_source: null,
delinquent: false,
description: null,
discount: null,
email: null,
invoice_prefix: '0BFDF721',
invoice_settings: {
custom_fields: null,
default_payment_method: null,
footer: null,
rendering_options: null
},
livemode: false,
metadata: {},
name: 'Test with stripe',
next_invoice_sequence: 1,
phone: null,
preferred_locales: [],
shipping: null,
tax_exempt: 'none',
test_clock: null
}
No I see 3 requests
yea me too
- req_3FCwBmlQPYfNmY
- req_kXJNGuAnaAlGTc
- req_XdHxuSQe2f8GCe
So your integration is sending 3 requests and not 2.
yea just checked the logs there are three requests
The one is returning an error is being retried apparently from your integration
stripe.customers
.create(
{ name: "Test with stripe" },
{
idempotencyKey: uniqueKey,
}
)
.then(result => {
console.dir(result, { depth: null });
})
.catch(error => {
console.error("ERROR BLOCK");
console.dir(error, { depth: null });
});
in my code i have just executed the block above twice
if in background somehow it ran 3 times it should return error for 1 request which failed
THere must be some catch/retry in your code/integration
Between, I'm not seeing any issue, the retru meecanisme working fine in your integration and you are creating one single Customer
from 3 requests with the same idempotency key
What is the issue here? I'm missing something ?
import Stripe from "stripe";
import { v4 as uuidv4 } from "uuid";
const stripe = new Stripe(
"sk_test_sdfgsdfg"
);
const uniqueKey = uuidv4();
stripe.customers
.create(
{ name: "Test with stripe" },
{
idempotencyKey: uniqueKey,
}
)
.then(result => {
console.dir(result, { depth: null });
})
.catch(error => {
console.error("ERROR BLOCK");
console.dir(error, { depth: null });
});
this is my complete code
The catch block is there but its not coming in that for that failed request
And how are you sending multiple request ?
If you just run the code above, this will send only one request.
i just copy pasted the stripe.customers.create function
so it will look like this
import Stripe from "stripe";
import { v4 as uuidv4 } from "uuid";
const stripe = new Stripe(
"sk_test_sdfgsdfg"
);
const uniqueKey = uuidv4();
stripe.customers
.create(
{ name: "Test with stripe" },
{
idempotencyKey: uniqueKey,
}
)
.then(result => {
console.dir(result, { depth: null });
})
.catch(error => {
console.error("ERROR BLOCK");
console.dir(error, { depth: null });
});
stripe.customers
.create(
{ name: "Test with stripe" },
{
idempotencyKey: uniqueKey,
}
)
.then(result => {
console.dir(result, { depth: null });
})
.catch(error => {
console.error("ERROR BLOCK");
console.dir(error, { depth: null });
});
Ok I see, the SDK is making the retry actually
https://docs.stripe.com/rate-limits#object-lock-timeouts:~:text=This object cannot,a lower rate.
but log shows 409 error
Yes it's the same subcategroy of request.
You are making two requests and the SDK is sending 3 requests (2 request with one automatically retried)
even if it retries the key should remain the same right?
The idempotency key you mean? yes the same will be used.
but if you see the customers list there is only one customer with that name, despite of having 3 requests
The 3 requests with the same idempotency key, will create only 1 customer.
ahhh
how do i ensure that i receive that error message?
No you won't, unless you set setMaxNetworkRetries to 0 I think
Why you want to get that error message between ? to do what exactly ?
we have our own retry mechanism and stuff so this can create confusion
worked thanks man
Thanks for help
you can close the thread