Immutable solution version
Requests not Throwing Errors in NestJS App or AWS Lambda Node 20/18.x
Complete solution
Shows how to fix requests not Throwing Errors in NestJS App or AWS Lambda Node 20/18.x. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "status, it should throw an exception that can be caught by a": note: maintainers (ramya-stripe) closed the issue without an SDK-side fix, as no self-contained repro was ever provided.
status, it should throw an exception that can be caught by aSteps
- Issue stripe/stripe-node#2231 (closed, 16 comments): ### Describe the bug
- Within NestJS, when performing calls such as
StripeClient.invoices.createor other operations with bad data, requests hang indefinitely and don't throw errors. - Instantiate Stripe Client with
new Stripe([API_KEY]) - Wrap API call in
try/catchblock - Call
invoices.createmethod with an invalid payload (Such as the one in the snippet) - Call will hang indefinitely neither erroring or succeeding
- When an API call fails on any non
2xxstatus, it should throw an exception that can be caught by atry/catchblock or - [Marlrus (reporter)]: Temporary workaround that unblocked the reporter: swap the HTTP client for node-fetch -
const httpClient = Stripe.createFetchHttpClient(fetch); const client = new Stripe(key, { httpClient });- calls stopped hanging. Note: maintainers (ramya-stripe) closed the issue without an SDK-side fix, as no self-contained repro was ever provided.
When to use
You are seeing this: Issue stripe/stripe-node#2231 (closed, 16 comments): ### Describe the bug Within NestJS, when performing calls such as StripeClient.invoices.create or other operations with bad data, requests hang indefinitely and don't throw errors. Use this skill when you run into "Requests not Throwing Errors in NestJS App or AWS Lambda Node 20/18.x".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Edge cases
- Note: maintainers (ramya-stripe) closed the issue without an SDK-side fix, as no self-contained repro was ever provided.
Evidence
Asked in gh:stripe/stripe-node#2231 (https://github.com/stripe/stripe-node/issues/2231): Requests not Throwing Errors in NestJS App or AWS Lambda Node 20/18.x. The issue report: Issue stripe/stripe-node#2231 (closed, 16 comments): ### Describe the bug
Within NestJS, when performing calls such as StripeClient.invoices.create or other operations with bad data, requests hang indefinitely and don't throw errors.
To Reproduce
- Instantiate Stripe Client with
new Stripe([API_KEY]) - Wrap API call in
try/catchblock - Call
invoices.createmethod with an invalid payload (Such as the one in the snippet) - Call will hang indefinitely neither erroring or succeeding
Expected behavior
When an API call fails on any non 2xx status, it should throw an exception that can be caught by a try/catch block or The verified answer: [Marlrus (reporter)]: Temporary workaround that unblocked the reporter: swap the HTTP client for node-fetch - const httpClient = Stripe.createFetchHttpClient(fetch); const client = new Stripe(key, { httpClient }); - calls stopped hanging. Note: maintainers (ramya-stripe) closed the issue without an SDK-side fix, as no self-contained repro was ever provided.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_et76uTsMLNpywpnjChxMWA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Requests not Throwing Errors in NestJS App or AWS Lambda Node 20/18.x <span>— Vectle</span></a>