-
Notifications
You must be signed in to change notification settings - Fork 176
improves states, chat status, reliability #166
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| } | ||
|
|
||
| const packageJsonRead = await runCommandInSandbox(sandbox, 'cat', ['package.json']) | ||
| const packageJsonRead = await runCommandInSandbox(sandbox, 'sh', ['-c', `cd ${PROJECT_DIR} && cat package.json`]) |
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.
The package.json existence check is performed in the root directory instead of the project directory, causing it to always fail since package.json is located at /vercel/sandbox/project/.
View Details
📝 Patch Details
diff --git a/app/api/tasks/[taskId]/restart-dev/route.ts b/app/api/tasks/[taskId]/restart-dev/route.ts
index 50e37e7..cf3ac3e 100644
--- a/app/api/tasks/[taskId]/restart-dev/route.ts
+++ b/app/api/tasks/[taskId]/restart-dev/route.ts
@@ -4,7 +4,7 @@ import { tasks } from '@/lib/db/schema'
import { eq } from 'drizzle-orm'
import { Sandbox } from '@vercel/sandbox'
import { getServerSession } from '@/lib/session/get-server-session'
-import { runCommandInSandbox, PROJECT_DIR } from '@/lib/sandbox/commands'
+import { runCommandInSandbox, runInProject, PROJECT_DIR } from '@/lib/sandbox/commands'
import { detectPackageManager } from '@/lib/sandbox/package-manager'
import { createTaskLogger } from '@/lib/utils/task-logger'
@@ -45,7 +45,7 @@ export async function POST(_request: NextRequest, { params }: { params: Promise<
const logger = createTaskLogger(taskId)
// Check if package.json exists and has a dev script
- const packageJsonCheck = await runCommandInSandbox(sandbox, 'test', ['-f', 'package.json'])
+ const packageJsonCheck = await runInProject(sandbox, 'test', ['-f', 'package.json'])
if (!packageJsonCheck.success) {
return NextResponse.json({ error: 'No package.json found in sandbox' }, { status: 400 })
}
Analysis
Incorrect working directory check for package.json in restart-dev endpoint
What fails: The /api/tasks/[taskId]/restart-dev endpoint always rejects requests with "No package.json found in sandbox" error, even when package.json exists in the project directory.
How to reproduce:
- Call POST
/api/tasks/[taskId]/restart-devfor any task with an active sandbox containing a Node.js project (has package.json in/vercel/sandbox/project/) - Endpoint returns 400 error: "No package.json found in sandbox"
Root cause: Line 48 in app/api/tasks/[taskId]/restart-dev/route.ts uses runCommandInSandbox(sandbox, 'test', ['-f', 'package.json']) which checks for the file in the sandbox root directory (/vercel/sandbox/), not the project directory where the repository is actually cloned (/vercel/sandbox/project/).
The subsequent line 53 correctly uses cd when reading the file, but by then the check has already failed.
Expected behavior: The package.json check should succeed when the file exists at /vercel/sandbox/project/package.json, consistent with how the same check is implemented in:
lib/sandbox/creation.tsline 172:await runInProject(sandbox, 'test', ['-f', 'package.json'])app/api/tasks/[taskId]/start-sandbox/route.tsline 124:await runInProject(sandbox, 'test', ['-f', 'package.json'])
Fix applied: Changed line 48 to use runInProject() which automatically changes to the PROJECT_DIR before executing the test command, matching the established pattern throughout the codebase.
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
No description provided.