Skip to content

Migration problems with form-data-parser #10402

Open
@Apsysikal

Description

@Apsysikal

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions