Skip to content

feat: improve error diagnostics for native module failures #30

@dwmkerr

Description

@dwmkerr

Problem

When node-pty fails to load (e.g., missing prebuilt binaries), users see a cryptic error:

Error: posix_spawnp failed.

No context on what went wrong or how to fix it.

Proposed Solutions

1. Startup diagnostics

Wrap node-pty import with helpful error handling:

let pty;
try {
  pty = await import('node-pty');
} catch (err) {
  console.error(`[shellwright] Failed to load node-pty native module.`);
  console.error(`[shellwright] This usually means compilation failed during install.`);
  console.error(`[shellwright] Try: npm install -g @dwmkerr/shellwright`);
  console.error(`[shellwright] Or install build tools: xcode-select --install (macOS)`);
  console.error(`[shellwright] Original error:`, err.message);
  process.exit(1);
}

2. Add --verbose flag

shellwright --verbose

Outputs:

  • Node version
  • Platform/arch
  • node-pty binding path
  • Any load errors

3. Document npx debugging

Add to README troubleshooting:

# See npx installation logs
npm_config_loglevel=verbose npx -y @dwmkerr/shellwright

# Or check npm cache
ls ~/.npm/_npx/*/node_modules/node-pty/build/

4. Health check endpoint (HTTP mode)

GET /health → { "status": "ok", "node_pty": "loaded", "version": "0.1.4" }

Acceptance Criteria

  • Startup catches node-pty load failures with actionable message
  • --verbose flag shows diagnostic info
  • README documents how to debug installation issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions