This repository reproduces a bug where client middleware context (sendContext) is not being passed to server middleware when using FormData with server functions.
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.
- Install dependencies:
pnpm install- Start the development server:
pnpm dev-
Open the app in your browser (default: http://localhost:3001)
-
Click the "Call Server Function" button
-
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!"
src/middleware.ts- Defines the test middleware with client and server handlerssrc/server-functions.ts- Server function that uses the middleware and accepts FormDatasrc/routes/index.tsx- UI that calls the server function to reproduce the bug
The testString created in the client middleware should be available in the server middleware's context parameter.
The testString is missing from the server middleware context when FormData is used.