Skip to content

"convex dev" CLI doesn't hot-reload when a dependent file is saved #73

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

Open
mfucek opened this issue Apr 24, 2025 · 2 comments
Open

"convex dev" CLI doesn't hot-reload when a dependent file is saved #73

mfucek opened this issue Apr 24, 2025 · 2 comments
Labels
question Further information is requested

Comments

@mfucek
Copy link

mfucek commented Apr 24, 2025

Hello 👋

Context

I have configured my project to have the convex directory under the src/deps folder.

{
	"$schema": "https://raw.githubusercontent.com/get-convex/convex-backend/refs/heads/main/npm-packages/convex/schemas/convex.schema.json",
	"functions": ["src/deps/convex", "src/modules/**/convex"]
}

Under src/deps/convex/schema.ts I have a task table which is imported from elsewhere.

import { taskTable } from '@/modules/task/convex/schema';
import { defineSchema } from 'convex/server';

export default defineSchema({
	task: taskTable
});

Problem

The problem is: the convex backend only refreshes if files under src/deps/convex change, but not when the imported dependent files change also - This results in having to redundantly save any file in the convex directory to see the changes reflected on the backend.

Any ideas how to overcome this issue? I am considering using Convex for a larger project with a large number of "modules" each having it's own table and functions. Having a neat folder structure is a must for such a use case.

Proposed solutions

1) Allow for specifying which folders the CLI should watch through a flag

  • A potential solution could look like this: bunx convex dev --watch src/modules/**/convex

2) Extending the schema so that dependent folders can be specified

{
	"$schema": "https://raw.githubusercontent.com/get-convex/convex-backend/refs/heads/main/npm-packages/convex/schemas/convex.schema.json",
	"root": "src/deps/convex"
	"dependencies": [
		"src/modules/post/convex",
		"src/modules/profile/convex",
		"src/modules/settings/convex"
	]
}

3) Allow for multiple functions directories to be specified

{
	"$schema": "https://raw.githubusercontent.com/get-convex/convex-backend/refs/heads/main/npm-packages/convex/schemas/convex.schema.json",
	"functions": ["src/deps/convex", "src/modules/**/convex"]
}
  • issue being where would the _generated folder be 🤔
@nipunn1313
Copy link
Collaborator

The pattern that the CLI is designed for - is to put the modules under the convex/ directory. If everything is in the configured convex/ directory, then convex dev will work as you're expecting. You can still have neat directory structure for separate tables.

Eg convex/post, convex/profile, convex/settings

Would that work for you?

Here's an example https://github.com/a16z-infra/ai-town/tree/main/convex (you can see engine as a module with a modularized schema.ts)

@nipunn1313
Copy link
Collaborator

From reading the source, my understanding is that the desired behavior is actually that any files that are read in the bundling phase become part of the observedDirectory set and are part of the file watcher for hot-reload. Thus, I would expect that even the dependencies you mentioned would be part of the hot reload process.

If you're able to make a small repo that reproes the issue, that would be amazing to help debug.

@nipunn1313 nipunn1313 added the question Further information is requested label Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants