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

client middleware export causes vite-plugin-tanstack-start-create-server-fn to throw error #3180

Open
thephilippbusch opened this issue Jan 16, 2025 · 0 comments

Comments

@thephilippbusch
Copy link

Which project does this relate to?

Start

Describe the bug

Creating and exporting a client middleware using createMiddleware().client() causes an internal server error with the following message:

Internal server error: createMiddleware must be called with a "use" property!

The bug seems to originate from vite-plugin-tanstack-start-create-server-fn

Full error message:

[vite] Internal server error: createMiddleware must be called with a "use" property!
  Plugin: vite-plugin-tanstack-start-create-server-fn
  File: /.../tanstack-start/app/middleware/logger.ts
      at Object.handleCreateMiddlewareCallExpression [as handleCallExpression] (file:///.../tanstack-start/node_modules/@tanstack/start-vite-plugin/dist/esm/compilers.js:261:11)
      at file:///.../tanstack-start/node_modules/@tanstack/start-vite-plugin/dist/esm/compilers.js:113:40
      at Array.forEach (<anonymous>)
      at file:///.../tanstack-start/node_modules/@tanstack/start-vite-plugin/dist/esm/compilers.js:112:44
      at Array.forEach (<anonymous>)
      at enter (file:///.../tanstack-start/node_modules/@tanstack/start-vite-plugin/dist/esm/compilers.js:111:24)
      at NodePath._call (/.../tanstack-start/node_modules/@babel/traverse/lib/path/context.js:49:20)
      at NodePath.call (/.../tanstack-start/node_modules/@babel/traverse/lib/path/context.js:39:18)
      at NodePath.visit (/.../tanstack-start/node_modules/@babel/traverse/lib/path/context.js:88:31)
      at TraversalContext.visitQueue (/.../tanstack-start/node_modules/@babel/traverse/lib/context.js:90:16)
      at TraversalContext.visitSingle (/.../tanstack-start/node_modules/@babel/traverse/lib/context.js:66:19)
      at TraversalContext.visit (/.../tanstack-start/node_modules/@babel/traverse/lib/context.js:113:19)
      at traverseNode (/.../tanstack-start/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
      at Module.traverse (/.../tanstack-start/node_modules/@babel/traverse/lib/index.js:53:34)
      at compileStartOutput (file:///.../tanstack-start/node_modules/@tanstack/start-vite-plugin/dist/esm/compilers.js:24:9)
      at TransformPluginContext.transform (file:///.../tanstack-start/node_modules/@tanstack/start-vite-plugin/dist/esm/index.js:44:24)
      at EnvironmentPluginContainer.transform (file:///.../tanstack-start/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:47224:19)
      at async loadAndTransform (file:///.../tanstack-start/node_modules/vite/dist/node/chunks/dep-BJP6rrE_.js:41034:27)

Your Example Website or App

https://github.com/thephilippbusch/tanstack-start

Steps to Reproduce the Bug or Issue

  1. Start the server using bun dev
  2. Open the app in a browser on port 3000
  3. See the error

Expected behavior

createMiddleware().client() to work properly

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome (Arc)
  • Runtime: bun

Additional context

I manually setup the project using the Build from Scratch guide from the docs.

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

No branches or pull requests

1 participant