-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Route files replaced with "Hello /route" boilerplate #2151
Comments
I haven't experienced this for a while now. That being said, we've done as much as we can to stop this from happening whilst the dev server is running. These are the checks we've added have so far: Checking that the router/packages/router-generator/src/generator.ts Lines 311 to 319 in 4d787a8
Only updating the written values for routes instead of pasting the full template. router/packages/router-generator/src/generator.ts Lines 341 to 357 in 4d787a8
Running a block when the generator is running to not double-run it. router/packages/router-plugin/src/router-generator.ts Lines 29 to 44 in 4d787a8
|
Happening to us too. Funnily enough, also when we are trying to demo our app to our boss! 😂 Workaround being to rollback using either Git, or webstorm's Local History We use a mix of Linux + Windows environments, also using git (with frequent updates on both ends) and Webstorm 2024.1.4 Node version: 20.11.0
My insights on the issue (albiet not as detailed as OP) It seems like some sort of race condition between I have witnessed once or twice the 'reset' files actually being a mash-up of the boilerplate + the real code (before reset). But most of the time when it does happen its just like the OP described. for example: import {createFileRoute} from '@tanstack/react-router'
import {PageHeader} from "@/components/PageHeader.tsx";
import {useSuspenseQuery} from "@tanstack/react-query";
import {Fab, List, MenuItem, Paper} from "@mui/material";
import {getProjects} from "@/api/queryOptions.ts";
import {HeroLink} from "@/components/HeroLink.tsx";
import {FilterList} from "@mui/icons-material";
import {useAppLayout} from "@/hooks/useAppLayout.tsx";
export const Route = createFileRoute('/_authenticated/projects')({
component: Projects
})
function Projects() {
const {data: projects} = useSuspenseQuery(getProjects());
const {bottomNavigationHeight} = useAppLayout();
return (
<>
<PageHeader title="Projects" />
<Paper>
<List>
{projects.map(p => (<MenuItem key={p.id} component={HeroLink} to={'/projects/$projectId'} params={{projectId: p.id}}>{p.projectName}</MenuItem>))}
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/_authenticated/projects')({
component: () => <div>Hello /_authenticated/projects!</div>
}) or the tanstack stuff at the start and then half of the real code after it - this makes me believe both are writing at the same time (for the record i'm the one on Windows) Another thing that may or may not be relevant, since both members of our team use different OS's, our line endings are different of course and each time a change is made to a route page we see that the routeTree.gen.ts updates but only line endings, shouldn't be a problem, but perhaps this causes some updates to files or something? or perhaps if some route pages are LF and others CRLF the checking for a route's existence doesnt work correctly? Does the generator use file-locks to encase the read + update of the file? |
Using vite with
@tanstack/router-plugin/vite
.Route files with real content are getting clobbered with boilerplate. i.e.
This has popped up a number of times, but doesn't happen consistently. Normally I just revert the file in my IDE.
But this time, at some point between testing some changes and committing the file it did the clobbering and I managed to lose all the changes and actually committed the boilerplate to source control. (yes i should have checked the diff)
Only just noticed a day later when I tried to demo the new route so I look like a doofus and the original content is not recoverable. 😿😿😿
Platform
I haven't tested with latest version but I did only update a few days ago.
My guess as to what's happening
Maybe git or the ide does something funny with the file which triggers the plugin into thinking the file is empty (and it might have been, briefly) and async operations between that tool and the route boilerplater get a bit tangled.
The text was updated successfully, but these errors were encountered: