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

Dead code elimination possibly being too aggressive #3104

Open
NickR49 opened this issue Jan 3, 2025 · 0 comments
Open

Dead code elimination possibly being too aggressive #3104

NickR49 opened this issue Jan 3, 2025 · 0 comments

Comments

@NickR49
Copy link

NickR49 commented Jan 3, 2025

Which project does this relate to?

Start

Describe the bug

In the dev env for this server function the code inisValidMove is only getting executed if the following console.log is there. The only side effect in isValidMove is console logging for dev/debug purposes. Is the dead code elimination being too aggressive in this case or is this as expected?

export const submitMoveSF = createServerFn({ method: 'POST' })
  .validator((data: string[]) => data)
  .handler(async ({ data: words }) => {
    console.log(` ---- submitMoveSF ---- `);
    const result = isValidMove(words);
    console.log(`Result: ${result ? 'true' : 'false'}`);

    return true;
  });

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-muerds5c?file=app%2Froutes%2Findex.tsx,app%2Futils%2Fexample.tsx,app%2Fshared%2Fmoves.ts&preset=node

Steps to Reproduce the Bug or Issue

  1. Run the above StackBlitz and press the Submit move button and ---- isValidMove ---- will appear in the server console showing that function was called by the submitMoveSF server function
  2. Comment out the console log on line 9 in submitMoveSF and press the Submit move button again - ---- isValidMove ---- no longer appears in the server console

Expected behavior

As a user I was expecting the code in isValidMove to run regardless of the presence of the console log in submitMoveSF

Screenshots or Videos

No response

Platform

  • macOS 15.2
  • Chrome 131, Opera 114
  • TanStack Router/Start 1.94.1

Additional context

No response

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