Use async functions within request handling code
See original GitHub issueIs your feature request related to a problem? Please describe.
Currently, there is a lot of setTimeout
s and other non-async-y code that means that we cannot take advantage of V8’s async stack trace feature. This means that we lose out on stack traces, the bare minimum that one would want for debugging an issue in production.
While support for the async stack trace feature came in Node 12, support for the async/await syntax (which would allow for users of newer node to get a stack trace) has been present from Node 7.
Describe the solution you’d like
At the very least, please use async
/await
syntax within the core request calling methods (StripeResource
, StripeMethod
), and remove usage of raw setTimeout
, instead doing things like await Promise((resolve, reject) => setTimeout(reject, 0))
to make sure that async stack traces are maintained.
Doing this pervasively should make the code easier to manage, reduce a lot of indentation, and be functionally equivalent given how this all works.
Describe alternatives you’ve considered
Monkeypatching is theoretically possible, and there are options to capture error traces myself, but that involves creating spurious error objects all over and increasing difficulties of updating stripe-node
.
Additional context
https://github.com/stripe/stripe-node/issues/1066 is an example of this issue
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Hey @rtpg
Thanks for your patience. We agree that this is crucial for the debugging experience. This would be a bit more than a quick fix and so we will be working on this in the coming months.
Thanks for getting back to us @rtpg We will take another look next week