Bun + Astro (Vite): Unexpected end of JSON input when using actions
What version of Bun is running?
1.1.18+5a0b93523
What platform is your computer?
Linux 6.9.6-200.fc40.x86_64 x86_64 unknown
What steps can reproduce the bug?
- Download Stackblitz example: https://stackblitz.com/edit/withastro-astro-pdghi3?file=src%2Fcomponents%2FLike.tsx
- Use
bun i - Run project with
bun run --bun dev - Access
localhost:4321 - Click on button near
Will return: Error: Unable to get API context. - Error
What is the expected behavior?
There is no Unexpected end of JSON input error and is returned an actual response (77)
npm run dev:
What do you see instead?
Image
Additional information
https://github.com/withastro/astro/issues/11423
I confirmed this issue occurs with the --bun flag, but goes away when running bun run dev. I'm not super familiar with the difference, but it sounds like bun switches back to node.js for Vite projects when --bun is omitted?
@bholmesdev , https://bun.sh/docs/cli/run#bun :
By default, Bun respects this shebang and executes the script with node. However, you can override this behavior with the
--bunflag. For Node.js-based CLIs, this will run the CLI with Bun instead of Node.js.
Update: we've found this issue is actually related to request.clone() dropping the response body. We see this is being tracked separately by Bun: https://github.com/oven-sh/bun/issues/6348
Should be safe to close this PR as a duplicate. Hope Bun can prioritize a fix on this!