@@ -154,22 +154,17 @@ export async function createSandbox({ files }: { files: z.infer<typeof benchifyF
154
154
155
155
console . log ( '=== COMPILATION ERROR CHECK ===' ) ;
156
156
157
- // Try multiple approaches to detect compilation errors
157
+ // Simplified approach - just try one quick check
158
158
try {
159
- // Approach 1: Try to build the project
160
- console . log ( 'Trying npm run build...' ) ;
161
- const buildCheck = await sandbox . commands . run ( 'cd /app && timeout 10s npm run build 2>&1 || true' ) ;
162
- console . log ( 'Build check output:' , buildCheck . stdout ) ;
163
- console . log ( 'Build check stderr:' , buildCheck . stderr ) ;
159
+ console . log ( 'Trying quick build check...' ) ;
160
+ const buildCheck = await sandbox . commands . run ( 'cd /app && timeout 5s npm run build 2>&1 || true' ) ;
161
+ console . log ( 'Build check output:' , buildCheck . stdout ?. substring ( 0 , 500 ) ) ;
164
162
165
163
if ( buildCheck . stdout && (
166
164
buildCheck . stdout . includes ( 'Unterminated string constant' ) ||
167
165
buildCheck . stdout . includes ( 'SyntaxError' ) ||
168
166
buildCheck . stdout . includes ( 'Unexpected token' ) ||
169
- buildCheck . stdout . includes ( 'Parse error' ) ||
170
- buildCheck . stdout . includes ( '[plugin:vite:' ) ||
171
- buildCheck . stdout . includes ( 'Transform failed' ) ||
172
- buildCheck . stdout . includes ( 'Build failed' )
167
+ buildCheck . stdout . includes ( '[plugin:vite:' )
173
168
) ) {
174
169
hasCompilationError = true ;
175
170
compilationErrorOutput = buildCheck . stdout ;
@@ -179,93 +174,9 @@ export async function createSandbox({ files }: { files: z.infer<typeof benchifyF
179
174
console . log ( 'Build check failed:' , buildError ) ;
180
175
}
181
176
182
- // Approach 2: Try to check TypeScript compilation
183
- if ( ! hasCompilationError ) {
184
- try {
185
- console . log ( 'Trying tsc --noEmit...' ) ;
186
- const tscCheck = await sandbox . commands . run ( 'cd /app && timeout 10s npx tsc --noEmit 2>&1 || true' ) ;
187
- console . log ( 'TypeScript check output:' , tscCheck . stdout ) ;
188
- console . log ( 'TypeScript check stderr:' , tscCheck . stderr ) ;
189
-
190
- if ( tscCheck . stdout && (
191
- tscCheck . stdout . includes ( 'error TS' ) ||
192
- tscCheck . stdout . includes ( 'Unterminated string constant' ) ||
193
- tscCheck . stdout . includes ( 'SyntaxError' )
194
- ) ) {
195
- hasCompilationError = true ;
196
- compilationErrorOutput = tscCheck . stdout ;
197
- console . log ( '✅ Found compilation error in TypeScript check' ) ;
198
- }
199
- } catch ( tscError ) {
200
- console . log ( 'TypeScript check failed:' , tscError ) ;
201
- }
202
- }
203
-
204
- // Approach 3: Try to parse files directly with Babel/ESLint
205
- if ( ! hasCompilationError ) {
206
- try {
207
- console . log ( 'Trying to parse main files...' ) ;
208
- const parseCheck = await sandbox . commands . run ( 'cd /app && timeout 10s npx babel src/App.tsx --presets=@babel/preset-typescript 2>&1 || true' ) ;
209
- console . log ( 'Parse check output:' , parseCheck . stdout ) ;
210
- console . log ( 'Parse check stderr:' , parseCheck . stderr ) ;
211
-
212
- if ( parseCheck . stderr && (
213
- parseCheck . stderr . includes ( 'Unterminated string constant' ) ||
214
- parseCheck . stderr . includes ( 'SyntaxError' ) ||
215
- parseCheck . stderr . includes ( 'Unexpected token' )
216
- ) ) {
217
- hasCompilationError = true ;
218
- compilationErrorOutput = parseCheck . stderr ;
219
- console . log ( '✅ Found compilation error in parse check' ) ;
220
- }
221
- } catch ( parseError ) {
222
- console . log ( 'Parse check failed:' , parseError ) ;
223
- }
224
- }
225
-
226
- // Approach 4: Check if the dev server is actually serving errors
227
- if ( ! hasCompilationError ) {
228
- try {
229
- console . log ( 'Checking dev server response for errors...' ) ;
230
- const responseCheck = await sandbox . commands . run ( 'cd /app && timeout 5s curl -s http://localhost:5173 2>&1 || true' ) ;
231
- console . log ( 'Response check output:' , responseCheck . stdout ) ;
232
-
233
- if ( responseCheck . stdout && (
234
- responseCheck . stdout . includes ( 'SyntaxError' ) ||
235
- responseCheck . stdout . includes ( 'Unterminated string' ) ||
236
- responseCheck . stdout . includes ( 'Parse error' ) ||
237
- responseCheck . stdout . includes ( 'Transform failed' )
238
- ) ) {
239
- hasCompilationError = true ;
240
- compilationErrorOutput = responseCheck . stdout ;
241
- console . log ( '✅ Found compilation error in dev server response' ) ;
242
- }
243
- } catch ( responseError ) {
244
- console . log ( 'Response check failed:' , responseError ) ;
245
- }
246
- }
247
-
248
- // Approach 5: Check Vite logs more thoroughly
249
- if ( ! hasCompilationError ) {
250
- try {
251
- console . log ( 'Checking for Vite process logs...' ) ;
252
- const viteLogsCheck = await sandbox . commands . run ( 'cd /app && ps aux | grep vite' ) ;
253
- console . log ( 'Vite processes:' , viteLogsCheck . stdout ) ;
254
-
255
- // Try to get logs from the running Vite process
256
- const viteLogCheck = await sandbox . commands . run ( 'cd /app && timeout 3s strace -p $(pgrep -f "vite --host") 2>&1 | head -20 || true' ) ;
257
- console . log ( 'Vite process trace:' , viteLogCheck . stdout ) ;
258
- } catch ( viteError ) {
259
- console . log ( 'Vite log check failed:' , viteError ) ;
260
- }
261
- }
262
-
263
177
console . log ( '=== COMPILATION ERROR CHECK SUMMARY ===' ) ;
264
178
console . log ( 'Has compilation error:' , hasCompilationError ) ;
265
179
console . log ( 'Compilation error output length:' , compilationErrorOutput . length ) ;
266
- if ( compilationErrorOutput ) {
267
- console . log ( 'Compilation error preview:' , compilationErrorOutput . substring ( 0 , 500 ) ) ;
268
- }
269
180
270
181
console . log ( 'Dev server started, output checked' ) ;
271
182
console . log ( 'Total build errors found:' , buildErrors . length ) ;
0 commit comments