-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat(workspace-packages): API watch and reload packages #1119
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
Conversation
✅ Deploy Preview for cedarjs canceled.
|
Greptile OverviewGreptile SummaryThis PR extends the API dev watcher to also watch the source trees of workspace packages that the API depends on (via Key integration points:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Dev as Developer
participant Watch as api-server/startWatch
participant WP as workspacePackages()
participant Ch as chokidar
participant BM as BuildManager
participant SM as serverManager
participant SDL as loadAndValidateSdls
Dev->>Watch: startWatch()
Watch->>WP: compute workspace globs
WP-->>Watch: [api/src, pkg/src/**]
Watch->>Ch: chokidar.watch(paths, ignored)
Ch-->>Watch: ready
Watch->>BM: run(clean=true)
BM->>SM: restartApiServer()
Watch->>SDL: validate SDLs
Ch-->>Watch: all(event, file)
alt file includes .sdl
Watch->>SDL: validate SDLs
alt invalid
Watch->>SM: killApiServer()
Watch-->>Dev: log schema error
Watch-->>Ch: return (skip rebuild)
end
end
Watch->>BM: cancelScheduledBuild()
alt event is add/unlink
Watch->>BM: run(rebuild=false)
else other events (change, etc.)
Watch->>BM: run(rebuild=true)
end
BM->>SM: restartApiServer()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
packages/api-server/src/watch.ts
Outdated
| const watcher = chokidar.watch( | ||
| watchPaths.map((p) => ensurePosixPath(p)), | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P0] workspacePackages() can generate invalid chokidar globs on Windows due to path.join() backslashes.
workspacePackages() returns patterns like ...\\src\\**\\* on Windows, and startWatch() only normalizes watch roots with ensurePosixPath (which likely doesn’t treat ** globs specially). This can result in chokidar not matching any workspace package files on Windows.
Consider normalizing the returned patterns from workspacePackages() to POSIX (or returning absolute dirs and letting chokidar handle recursion) instead of mixing path.join + globs.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/api-server/src/watch.ts
Line: 125:127
Comment:
[P0] `workspacePackages()` can generate invalid chokidar globs on Windows due to `path.join()` backslashes.
`workspacePackages()` returns patterns like `...\\src\\**\\*` on Windows, and `startWatch()` only normalizes watch roots with `ensurePosixPath` (which likely doesn’t treat `**` globs specially). This can result in chokidar not matching any workspace package files on Windows.
Consider normalizing the returned patterns from `workspacePackages()` to POSIX (or returning absolute dirs and letting chokidar handle recursion) instead of mixing `path.join` + globs.
How can I resolve this? If you propose a fix, please make it concise.
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run-many -t build |
✅ Succeeded | 3m 24s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-02-01 21:57:12 UTC
|
Related Documentation No published documentation to review for changes on this repository. |
|
The changes in this PR are now available in 3.0.0-canary.13322+8fb222b6a |

The script that runs the api server in dev used on only restart the server when any of the files in the api workspace changes. I've now extended this logic to also watch and restart when workspace packages the api side uses changes