-
Notifications
You must be signed in to change notification settings - Fork 130
fix(next-js): auto shut down runners when source code updates #3369
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
fix(next-js): auto shut down runners when source code updates #3369
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
PR Review: Auto Shut Down Runners on Source Code UpdatesSummaryThis PR adds a file watching mechanism to automatically shut down Next.js runners when source code is updated during development. The implementation uses polling instead of filesystem watchers to avoid cross-platform issues. Code Quality & Best PracticesStrengths:
Issues & Suggestions:
Potential Bugs
Performance Considerations
Security ConcernsNo significant security issues identified. The file watching is limited to development mode and watches a build artifact, not user input. Test CoverageMissing Tests:
Additional Recommendations
VerdictThe implementation solves a real problem with Next.js hot reloading, but needs refinement around:
The approach is reasonable given Next.js limitations, but the hardcoded path and per-request watchers are blockers that should be addressed before merging. |
e376715 to
943ae66
Compare
PR Review: Auto shut down runners when source code updatesSummaryThis PR implements a development-mode file watcher that automatically shuts down runners when Next.js hot-reloads route files. The implementation addresses a legitimate issue where long-running requests (like SSE streams) persist across hot reloads in development. Code Quality & Best PracticesStrengths:
Issues:
Potential Bugs
Performance Considerations
Security Concerns
Test CoverageMissing tests:
Recommended test cases: describe("handleRequestWithFileWatcher", () => {
it("should clean up interval when stream finishes");
it("should clean up interval when request is aborted");
it("should clean up interval immediately if no response body");
it("should abort merged controller when file changes");
it("should handle file stat errors gracefully");
});Additional Recommendations
SummaryThe PR solves a real development experience problem with a practical workaround. The implementation is generally solid, but has several issues that should be addressed: Must fix:
Should fix:
Nice to have:
The core logic is sound, but the edge cases and cleanup paths need attention to prevent subtle bugs in production. |
3763786 to
fdd89a7
Compare
943ae66 to
d42c437
Compare
d42c437 to
ddef08f
Compare
Pull Request ReviewOverviewThis PR implements automatic shutdown of runners when source code updates in Next.js development mode. The implementation adds file watching functionality to detect changes and gracefully abort running requests. Code Quality & Best PracticesPositive aspects:
Suggestions:
Potential Bugs
Performance Considerations
Security ConcernsNo significant security issues identified. The code:
Test CoverageThe PR doesn't include tests. Consider adding:
Additional Recommendations
SummaryThe implementation is well-structured and solves a real development pain point with Next.js hot reloading. The main concerns are:
Overall, this is a solid solution to a tricky problem. With the fixes above, this should be ready to merge. |
Pull Request ReviewSummaryThis PR implements auto-shutdown of runners when source code updates in Next.js development mode. The solution uses a polling-based file watcher to detect changes to the compiled route file and gracefully aborts requests to trigger runner restarts. Code Quality & Best PracticesPositive Aspects
Suggestions for Improvement1. Environment check inconsistency (mod.ts:58) 2. Potential memory leak with abort listeners (mod.ts:93, 102) 3. Hard-coded route path (mod.ts:160-163) Potential Bugs & IssuesCritical Issues1. Race condition in file watcher (mod.ts:166-193) 2. Incomplete comment in actor-driver.ts:652 3. Body stream consumption issue (mod.ts:108-120) Medium Priority Issues4. Interval not cleared on immediate abort (mod.ts:99-105) 5. Error handling in stream wrapper (mod.ts:218-221) Performance Considerations1. Polling every 1 second per request (mod.ts:192) 2. Synchronous file system calls (mod.ts:169, 173) Security Concerns1. Development-only feature - File watching is properly restricted to development mode. No security concerns for production deployments. 2. Path traversal protection - Hard-coded path with join() prevents path traversal. No user input in file path construction. 3. Resource exhaustion potential - Multiple concurrent requests each create an interval. An attacker could open many connections to consume CPU/memory. Mitigation: This is development-only, so risk is minimal. Recommendation: Consider adding a maximum concurrent watcher limit. Test CoverageMissing Tests: No test files found for next-js package. Critical path (file watching, stream wrapping, abort handling) is untested. Recommendation: Add tests for file change detection, interval cleanup, stream wrapper behavior, memory leak prevention, and edge cases. Summary & RecommendationsPriority Fixes:
Nice to Have:
Overall Assessment: Recommended Action: Request changes to fix the critical environment check issue and file creation race condition. Other issues can be addressed in follow-up PRs. |

No description provided.