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

Migration problems with form-data-parser #10402

Open
Apsysikal opened this issue Jan 11, 2025 · 0 comments
Open

Migration problems with form-data-parser #10402

Apsysikal opened this issue Jan 11, 2025 · 0 comments

Comments

@Apsysikal
Copy link

Reproduction

I am working on migrating my remix app to react-router and am now stuck on this part: https://remix.run/docs/en/main/start/future-flags#multipart-form-data-and-file-upload-utilities
I've updated my actions to this:

const uploadHandler = async (fileUpload: FileUpload) => {
  let storageKey = getStorageKey("temporary-key");
  await fileStorage.set(storageKey, fileUpload);
  return fileStorage.get(storageKey);
};

const formData = await parseFormData(request, uploadHandler);

This works when i run the dev-server. But when i run a production-build the formData is empty. Does anyone know how this could be happening?
When i do

const formData = await request.formData();

I see the formData is present on the request. After I do that the parseFormData functions complains about the stream being locked.

My vite config looks like this:

import mdx from "@mdx-js/rollup";
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

declare module "@remix-run/server-runtime" {
  // or cloudflare, deno, etc.
  interface Future {
    v3_singleFetch: true;
  }
}

export default defineConfig({
  server: { port: 3000 },
  plugins: [
    mdx(),
    remix({
      future: {
        v3_fetcherPersist: true,
        v3_relativeSplatPath: true,
        v3_throwAbortReason: true,
        v3_singleFetch: true,
        v3_lazyRouteDiscovery: true,
        v3_routeConfig: true,
      },
    }),
    tsconfigPaths(),
  ],
});

My routes config looks like this:

import { flatRoutes } from "@remix-run/fs-routes";

export default flatRoutes();

A route not yet migrated still works:

const formData = await request.formData();

Any guidance would be appreciated

System Info

System:
    OS: Linux 6.5 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (12) arm64 unknown
    Memory: 4.92 GB / 7.66 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 20.18.0 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 9.12.1 - /usr/local/share/npm-global/bin/pnpm
  npmPackages:
    @remix-run/dev: ^2.15.2 => 2.15.2 
    @remix-run/fs-routes: ^2.15.2 => 2.15.2 
    @remix-run/node: ^2.15.2 => 2.15.2 
    @remix-run/react: ^2.15.2 => 2.15.2 
    @remix-run/route-config: ^2.15.2 => 2.15.2 
    @remix-run/serve: ^2.15.2 => 2.15.2 
    vite: ^6.0.5 => 6.0.7

Used Package Manager

npm

Expected Behavior

Continue working as before migration

Actual Behavior

Breaks in the production build of Vite. The formData is always empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant