QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.83k stars 1.31k forks source link

[🐞] routeAction$ broken in Bun adapter #5362

Open joshdchang opened 1 year ago

joshdchang commented 1 year ago

Which component is affected?

Qwik City (routing)

Describe the bug

When using the Bun adapter, whenever you try to capture a Form using a routeAction$, it fails, giving the following error. This only occurs using bun run serve. The dev server works fine.

Error: NOTCONN
1014 | var parseRequest = async (request, sharedMap, qwikSerializer) => {
1015 |   var _a2;
1016 |   const req = request.clone();
1017 |   const type = ((_a2 = request.headers.get("content-type")) == null ? void 0 : _a2.split(/[;,]/, 1)[0].trim()) ?? "";
1018 |   if (type === "application/x-www-form-urlencoded" || type === "multipart/form-data") {
1019 |     const formData = await req.formData();
                               ^
TypeError: FormData parse error missing final boundary
      at /Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:1019:27
      at parseRequest (/Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:1014:26)
      at /Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:970:27
      at parseBody (/Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:966:15)
      at /Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:379:29
      at /Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:356:16
      at /Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:822:21
      at next (/Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:818:15)
      at /Users/josh/Desktop/qwik-bug/server/entry.bun.mjs:641:12

This is the entire code for the page (Tailwind classes omitted for clarity):

import { component$ } from "@builder.io/qwik";
import { Form, routeAction$ } from "@builder.io/qwik-city";

export const useAction = routeAction$((data) => {
  console.log("data", data);
  return { success: true };
});

export default component$(() => {
  const action = useAction();
  return (
    <>
      <Form action={action}>
        <input type="text" name="name" placeholder="Name" />
        <button type="submit">Submit</button>
      </Form>
    </>
  );
});

See the reproduction

Reproduction

https://github.com/joshdchang/qwik-bug

Steps to reproduce

  1. Clone https://github.com/joshdchang/qwik-bug.
  2. bun run build
  3. bun run serve
  4. Submit the form

System Info

System:
    OS: macOS 14.0
    CPU: (8) arm64 Apple M2
    Memory: 112.23 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.8.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.1.0 - /usr/local/bin/npm
    pnpm: 8.5.0 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 118.0.5993.117
    Safari: 17.0
  npmPackages:
    @builder.io/qwik: ^1.2.15 => 1.2.15 
    @builder.io/qwik-city: ^1.2.15 => 1.2.15 
    undici: ^5.26.0 => 5.27.0 
    vite: ^4.5.0 => 4.5.0

Additional Information

No response

gioboa commented 1 year ago

Is it a bun only issue? Did you try with a different adapter?

joshdchang commented 1 year ago

Is it a bun only issue? Did you try with a different adapter?

I tried on node and cloudflare-pages, neither of which had an issue.

mhevery commented 1 year ago

This seems like an issue in Bun?