(code, signal)
| 523 | } |
| 524 | |
| 525 | function printCrashDiagnostics(code, signal) { |
| 526 | // Windows NTSTATUS codes (unsigned DWORD) |
| 527 | const unsignedCode = getUnsignedExitCode(code) |
| 528 | const isIllegalInstruction = |
| 529 | signal === 'SIGILL' || |
| 530 | (process.platform === 'win32' && unsignedCode === 0xC000001D) |
| 531 | const isAccessViolation = |
| 532 | signal === 'SIGSEGV' || |
| 533 | (process.platform === 'win32' && unsignedCode === 0xC0000005) |
| 534 | const isBusError = signal === 'SIGBUS' |
| 535 | const isAbort = |
| 536 | signal === 'SIGABRT' || |
| 537 | (process.platform === 'win32' && unsignedCode === 0xC0000409) |
| 538 | |
| 539 | if (!isIllegalInstruction && !isAccessViolation && !isBusError && !isAbort) return |
| 540 | |
| 541 | const exitInfo = signal ? `signal ${signal}` : `code ${code}` |
| 542 | console.error('') |
| 543 | console.error(`❌ ${packageName} exited immediately (${exitInfo})`) |
| 544 | console.error('') |
| 545 | |
| 546 | if (isIllegalInstruction) { |
| 547 | console.error('Your CPU may not support the required instruction set (AVX2).') |
| 548 | console.error('This typically affects CPUs from before 2013.') |
| 549 | console.error('Unfortunately, this binary is not compatible with your system.') |
| 550 | console.error('') |
| 551 | } else if (isAccessViolation) { |
| 552 | console.error('The binary crashed with an access violation.') |
| 553 | console.error('') |
| 554 | } else if (isBusError) { |
| 555 | console.error('The binary crashed with a bus error.') |
| 556 | console.error('This may indicate a platform compatibility issue.') |
| 557 | console.error('') |
| 558 | } else if (isAbort) { |
| 559 | console.error('The binary crashed with an abort signal.') |
| 560 | console.error('') |
| 561 | } |
| 562 | |
| 563 | console.error('System info:') |
| 564 | console.error(` Platform: ${process.platform} ${process.arch}`) |
| 565 | console.error(` Node: ${process.version}`) |
| 566 | console.error(` Binary: ${CONFIG.binaryPath}`) |
| 567 | console.error('') |
| 568 | console.error('Please report this issue at:') |
| 569 | console.error(' https://github.com/CodebuffAI/codebuff/issues') |
| 570 | console.error('') |
| 571 | } |
| 572 | |
| 573 | async function main() { |
| 574 | console.log('\x1b[1m\x1b[91m' + '='.repeat(60) + '\x1b[0m') |
no test coverage detected