Skip to content
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

Bun + Astro (Vite): Unexpected end of JSON input when using actions #12435

Open
ynhhoJ opened this issue Jul 8, 2024 · 3 comments
Open

Bun + Astro (Vite): Unexpected end of JSON input when using actions #12435

ynhhoJ opened this issue Jul 8, 2024 · 3 comments
Labels
bug Something isn't working needs triage

Comments

@ynhhoJ
Copy link

ynhhoJ commented Jul 8, 2024

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?

  1. Download Stackblitz example: https://stackblitz.com/edit/withastro-astro-pdghi3?file=src%2Fcomponents%2FLike.tsx
  2. Use bun i
  3. Run project with bun run --bun dev
  4. Access localhost:4321
  5. Click on button near Will return: Error: Unable to get API context.
  6. 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:
image

What do you see instead?

Image

image

Additional information

withastro/astro#11423

@ynhhoJ ynhhoJ added bug Something isn't working needs triage labels Jul 8, 2024
@ynhhoJ ynhhoJ changed the title Bun: Unexpected end of JSON input Bun + Astro: Unexpected end of JSON input when using actions Jul 8, 2024
@ynhhoJ ynhhoJ changed the title Bun + Astro: Unexpected end of JSON input when using actions Bun + Astro (Vite): Unexpected end of JSON input when using actions Jul 8, 2024
@bholmesdev
Copy link

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?

@ynhhoJ
Copy link
Author

ynhhoJ commented Jul 12, 2024

@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 --bun flag. For Node.js-based CLIs, this will run the CLI with Bun instead of Node.js.

@bholmesdev
Copy link

bholmesdev commented Aug 2, 2024

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: #6348

Should be safe to close this PR as a duplicate. Hope Bun can prioritize a fix on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants