allen
allen11mo ago

WebStorm File Cache Conflict on File Save

When working on Convex api function file and saving them, I seem to be getting the attached warning ~50% of the time from WebStorm. I have never experienced this before while working with Convex and wondering if anyone has a solution. Error text:

Changes have been made to '/(...)/convex/_generated/api.d.ts' in memory and on disk.
[ Keep Memory Changes | Show Difference | Load File System Changes ]

Changes have been made to '/(...)/convex/_generated/api.d.ts' in memory and on disk.
[ Keep Memory Changes | Show Difference | Load File System Changes ]
No description
18 Replies
ballingt
ballingt11mo ago
Hm, I wonder if it's some autoformatting, newline removal, etc. that the editor does each time. If you can figure out what the changes are (what does Show Difference say?) that might be a hint
allen
allenOP11mo ago
I'll keep my eye on it and report back Just triggered again, this time when renaming a file. The diff shows the change in the api name for the function, along with some alphabetical sorting related to the change. What you'd expect to be generated. I'm wondering if its related to some errors I just noticed in my convex dev terminal window. Seems its required that I have use node in actions that depend on imports that have the use node declaration -- For some reason I recall that being inherited. Perhaps this was some api.d.ts file updates and then immediate rollbacks due to the error? I believe it has to do something with how the api types are being generated and it relating to errors. I'm noticing it more frequently when I tab away from webstorm with partial edits. The blur event causes a file save, which triggers convex codegen, which ultimately shows this ide error (because of partial edits during the blur event not validating correctly). I didnt notice this behavior in my other convex project (v1.6). Could something have been introduced in 1.7-1.9 to cause this?
ballingt
ballingt11mo ago
Possibly, I'm looking through changes. I wonder what we could do better here. On blur/save we can usually prove that there's no need to regenerate unless the names or number of files in the convex/ directory has changed. But it sounds like you see this even when it's just a small change to a file?
The diff shows the change in the api name for the function, along with some alphabetical sorting related to the change. What you'd expect to be generated.
Is it ever just sorting, or is there always a line being added/removed?
allen
allenOP11mo ago
could be a new file thats partially worked let me try to replicate
ballingt
ballingt11mo ago
The codegen does read the file, but only to check that at least one line begins with "import" or "export." It doesn't check the names of the exports or anything else.
allen
allenOP11mo ago
i assume unrelated, but the ⠏ Backfilling indexes and checking that documents match your schema... step seems to be taking forever, and this fresh project with next to no data.
ballingt
ballingt11mo ago
That looking for "import" or "export" behavior to avoid importing empty files (which TypeScript has trouble analyzing) was added 1.4.1
allen
allenOP11mo ago
I cant seem to reliably reproduce this issue, either with new files or making edits to existing.
ballingt
ballingt11mo ago
I'll follow up on this soon, about to start looking at improving performance of these If you hit one of these feel free to send me the diff, at minimum these diffs should always be meaningful (adding/removing files from the list) and if there are common editing operations that make these change we can think about changing the codegen. I hope the workaround of keeping this _generated/api.d.ts file closed works, but I know I have a tendency to never close these
allen
allenOP11mo ago
Will do. When I have checked the diff its meaningful... it looks like the expected update. I'm just unsure why its suddenly causing an in memory collision with webstorm. I dont even have that file open in my IDE
ballingt
ballingt11mo ago
oh interesting!
allen
allenOP11mo ago
I understand this is a crap bug report. Mainly was hoping someone else had seen it before and had a solution. I'm starting to feel like I'm the only one deving using WebStorm these days though.
ballingt
ballingt11mo ago
poking around I see suggested workarounds for similar-sounding issues like external formatters to disable "safe write" (saving to memory? / temporary file? between saves)
allen
allenOP11mo ago
just odd that I have never seen this before. Is there a change to how you are writing to disk in codegen?
ballingt
ballingt11mo ago
not even having the file open is pretty interesting
allen
allenOP11mo ago
My webstorm version is from March 15 2023, so I cant imagine its something there...
ballingt
ballingt11mo ago
as I was just starting to look through webstorm changelogs, that's helpful to know that something big hasn't changed there What was the last date or Convex version that didn't do this?
allen
allenOP11mo ago
My other project is using 1.6.3

Did you find this page helpful?