From 88993f36629206a7bdcf9aa9d5641f1580b64de5 Mon Sep 17 00:00:00 2001 From: Thomas Hallock Date: Mon, 3 Nov 2025 12:17:29 -0600 Subject: [PATCH] fix: tolerate OpenSCAD CGAL warnings if output file is created MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OpenSCAD 2021.01 (Debian stable) has CGAL geometry bugs that cause non-zero exit status when processing complex STL operations, but it still produces valid output files. Instead of failing the job when OpenSCAD exits with non-zero status, we now check if the output file was created. If it exists, we proceed with the job. Only if the file is missing do we treat it as a failure. This allows 3D model generation to work on production despite the older OpenSCAD version's CGAL warnings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/web/src/lib/3d-printing/jobManager.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/web/src/lib/3d-printing/jobManager.ts b/apps/web/src/lib/3d-printing/jobManager.ts index 544bed03..30798cd3 100644 --- a/apps/web/src/lib/3d-printing/jobManager.ts +++ b/apps/web/src/lib/3d-printing/jobManager.ts @@ -122,18 +122,29 @@ export class JobManager { console.log(`Executing: ${cmd}`) // Execute OpenSCAD (with 60s timeout) + // Note: OpenSCAD may exit with non-zero status due to CGAL warnings + // but still produce valid output. We'll check file existence afterward. try { await execAsync(cmd, { timeout: 60000, cwd: join(process.cwd(), 'public', '3d-models'), }) } catch (execError) { - // Log detailed error information - console.error(`OpenSCAD execution failed:`, execError) - if (execError instanceof Error) { - throw new Error(`OpenSCAD error: ${execError.message}`) + // Log the error but don't throw yet - check if output was created + console.warn(`OpenSCAD reported errors, but checking if output was created:`, execError) + + // Check if output file exists despite the error + try { + await readFile(outputPath) + console.log(`Output file created despite OpenSCAD warnings - proceeding`) + } catch (readError) { + // File doesn't exist, this is a real failure + console.error(`OpenSCAD execution failed and no output file created:`, execError) + if (execError instanceof Error) { + throw new Error(`OpenSCAD error: ${execError.message}`) + } + throw execError } - throw execError } job.progress = 'Finalizing...'