-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some Stripe API calls failing in production since upgrading from Bun 1.0.x to Bun 1.1.x #10975
Comments
@nathankleyn can you give it a try in Bun v1.1.8? @nektro fixed some things in node:http which might help here (notably: adding bun upgrade --canary |
@Jarred-Sumner Thanks for super fast reply! On it and will report back ASAP 👀 👍 |
@Jarred-Sumner Just gave it a go in production with Let me know if there's anything I can do to help make this more easily reproducible or test anything at all, we're at your disposal as I know the case above is not easy to reproduce standalone! |
@nathankleyn if you start the script with
|
In Bun v1.0, for better overall ecosystem compatibility, we removed the `"worker"` package.json `"exports"` condition which unfortunately caused `"stripe"` to load the `"node:http"`-based implementation. This `"node:http"`-based implementation usually works fine, however there is an edgecase involving `https.Agent` having the wrong `protocol` set, (causing errors)[oven-sh/bun#10975] when a request is retried. This is a difficult to reproduce bug in Bun and not in `stripe`. However, in Bun, `"node:http"` internally is implemented as a wrapper on top of `fetch`. So `"stripe"` might as well skip the wrapper and just use fetch instead, assuming that is not a breaking change in of itself. If we add the `BUN_JSC_dumpModuleLoadingState=1` environment variable, Bun logs some information about which modules have loaded. Bun v0.6.1: ```js ❯ BUN_JSC_dumpModuleLoadingState=1 bun-0.6.1 terminy.js 2>&1 | rg "\.esm.*.js" Loader [resolve] ./node_modules/stripe/esm/stripe.esm.worker.js Loader [fetch] ./node_modules/stripe/esm/stripe.esm.worker.js loader [parsing] ./node_modules/stripe/esm/stripe.esm.worker.js Loader [link] ./node_modules/stripe/esm/stripe.esm.worker.js Loader [evaluate] ./node_modules/stripe/esm/stripe.esm.worker.js ``` Bun v1.1.7: ```js ❯ BUN_JSC_dumpModuleLoadingState=1 bun-1.1.7 terminy.js 2>&1 | rg "\.esm.*.js" Loader [fetch] ./node_modules/stripe/esm/stripe.esm.node.js loader [parsing] ./node_modules/stripe/esm/stripe.esm.node.js Loader [link] ./node_modules/stripe/esm/stripe.esm.node.js Loader [evaluate] ./node_modules/stripe/esm/stripe.esm.node.js ```
Hey @Jarred-Sumner — thanks so much yet again for the super speed reply and debugging here! I can confirm adding Thank you so much for helping us get back up and running again — if there anything we can do to assist with the proper fix from here to the agent change, we're super happy to test or reproduce anything that you need. We'll also keep an eye on that Stripe PR you raised and see what happens once that gets merged too. |
@Jarred-Sumner it seems like the PR has been merged but I just ran in to this issue. It was definitely an issue with Bun as when I tried it with Node it worked fine. I'm using Bun 1.1.20. |
What version of Bun is running?
1.1.7+b0b7db5c0
What platform is your computer?
Linux 5.15.60+ x86_64 unknown
What steps can reproduce the bug?
oven/bun:1.1.7-debian
to Google Cloud RunWhat is the expected behavior?
The call should work and return an object of the form:
What do you see instead?
The call fails with an exception:
Caused by:
Additional information
The actual response from the Stripe API under the covers is:
The URL of the API Stripe is actually calling to is to:
^ Note the
http
but the port:443
.It seems that before Bun 1.1.0, the
https
was being inferred because of the port (?) but on every version between 1.1.0 and 1.1.7 thehttp
is being left causing this error upstream.It's worth noting that I cannot seem to reproduce this issue outside of GCP — it only seems to happen there. If I try to run the same Docker container on Orbstack locally, or the app directly on MacOS, all works fine — this is mystifying as I'm trying to make it reproducible for you but have really struggled to make it easier!
Our company is encountering this issue in production which is blocking us from upgrading to Bun 1.1.x. Pinning to Bun 1.0.36 resolves the issue.
The text was updated successfully, but these errors were encountered: