fix: tolerate OpenSCAD CGAL warnings if output file is created

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 <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-11-03 12:17:29 -06:00
parent 458cc2b918
commit 88993f3662
1 changed files with 16 additions and 5 deletions

View File

@ -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...'