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

Bug: compiler error on arrow function implicit return in server functions - Invariant failed: createServerFn must be called with a function that is marked with the 'use server' pragma. #2441

Open
SeyyedKhandon opened this issue Sep 29, 2024 · 0 comments
Labels
bug Something isn't working start Everything about TanStack Start

Comments

@SeyyedKhandon
Copy link

SeyyedKhandon commented Sep 29, 2024

Which project does this relate to?

Start

Describe the bug

This issue is a follow up for #2434 discussion:

This server function:

const getHashId = createServerFn("GET", () => storage.hashId);

results in :

Invariant failed: createServerFn must be called with a function that is marked with the 'use server' pragma. Are you using the @tanstack/router-plugin/vite ?

while it works for:

const getHashId = createServerFn("GET", () => {
  return storage.hashId;
});

Your Example Website or App

#2434

Steps to Reproduce the Bug or Issue

  1. just use an arrow function with implicit return

Expected behavior

As a user I expect it to support javascript syntax correctly, which means it should support any variant of functions that we pass to be considered a fully javascript compatible.

Screenshots or Videos

Image

Platform

  • OS: Macos 15 sequia
  • Browser: Chrome 129.0.6668.60

Additional context

No response

@SeyyedKhandon SeyyedKhandon changed the title Compiler error on arrow function implicit return in server functions - Invariant failed: createServerFn must be called with a function that is marked with the 'use server' pragma. Bug: Compiler error on arrow function implicit return in server functions - Invariant failed: createServerFn must be called with a function that is marked with the 'use server' pragma. Sep 29, 2024
@SeyyedKhandon SeyyedKhandon changed the title Bug: Compiler error on arrow function implicit return in server functions - Invariant failed: createServerFn must be called with a function that is marked with the 'use server' pragma. Bug: compiler error on arrow function implicit return in server functions - Invariant failed: createServerFn must be called with a function that is marked with the 'use server' pragma. Sep 29, 2024
@SeanCassiere SeanCassiere added bug Something isn't working start Everything about TanStack Start labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working start Everything about TanStack Start
Projects
None yet
Development

No branches or pull requests

2 participants