Skip to content

Improve error handling and logging in scenario execution #10

@alanops

Description

@alanops

Problem

The server lacks comprehensive error handling and logging for scenario execution, making debugging difficult.

Current Issues

  1. No try-catch blocks around critical operations
  2. stderr is sent to client but not logged server-side
  3. No validation of Docker daemon availability
  4. Fixed 2-second delay for readiness instead of actual checks
  5. No cleanup on error conditions

Current Code Issues

// No error handling here:
const child = spawn('docker', args);

// Fixed delay instead of readiness check:
setTimeout(() => {
  socket.emit('scenario-ready');
}, 2000);

// Limited error info:
child.on('error', (error) => {
  socket.emit('output', `Error: ${error.message}\n`);
});

Expected Behavior

  • Comprehensive error logging on server
  • Meaningful error messages to users
  • Proper cleanup of failed containers
  • Health checks for container readiness
  • Graceful handling of Docker daemon issues

Solution

  1. Add try-catch blocks around spawn operations
  2. Implement proper logging (console.error at minimum)
  3. Add Docker daemon connectivity check on startup
  4. Replace fixed delays with actual readiness probes
  5. Ensure cleanup of resources on all error paths

Impact

  • Difficult to debug issues in production
  • Users see cryptic errors
  • Potential resource leaks from unclean shutdowns

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions