Skip to content

empotts/tanstack-middleware-formdata-bug

Repository files navigation

TanStack Middleware FormData Bug Reproducer

This repository reproduces a bug where client middleware context (sendContext) is not being passed to server middleware when using FormData with server functions.

Bug Description

When a middleware defines both client and server handlers, and the client handler sends context via sendContext, this context should be available in the server middleware's context parameter. However, when the server function accepts FormData, the context is missing.

How to Reproduce

  1. Install dependencies:
pnpm install
  1. Start the development server:
pnpm dev
  1. Open the app in your browser (default: http://localhost:3001)

  2. Click the "Call Server Function" button

  3. Check the browser console and server logs:

    • The client middleware creates a test string and logs it
    • The server middleware should receive this string in the context, but it's missing
    • An error will be thrown: "BUG REPRODUCED: testString is missing from server middleware context!"

Files Related to the Bug

  • src/middleware.ts - Defines the test middleware with client and server handlers
  • src/server-functions.ts - Server function that uses the middleware and accepts FormData
  • src/routes/index.tsx - UI that calls the server function to reproduce the bug

Expected Behavior

The testString created in the client middleware should be available in the server middleware's context parameter.

Actual Behavior

The testString is missing from the server middleware context when FormData is used.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published