ZoopFlow Troubleshooting Guide
This guide provides comprehensive troubleshooting techniques, common problems, and solutions for ZoopFlow. Use this as a reference when encountering issues in development or production environments.
Introduction to Troubleshooting in ZoopFlow
ZoopFlow combines several technologies and paradigms, including:
- Temporal.io for workflow orchestration
- TypeScript-based flow and step definitions
- Schema validation with ZSchema
- Signal handling for flow interaction
- State management across distributed workflows
Troubleshooting effectively requires understanding how these components interact. This guide organizes common issues by component area and provides structured approaches to diagnosing and resolving problems.
Common Issues and Solutions
Flow Definition Issues
Invalid Flow Structure
Symptoms:
- Error message:
Invalid flow structure: Missing required nodes - Flow fails to register or execute
Causes:
- Missing start/end nodes
- Disconnected nodes in the flow graph
- Circular dependencies between steps
Solution:
- Validate flow definition structure:
import { validateFlowDefinition } from '@zoopflow/core'; const validationResult = validateFlowDefinition(flowDefinition); if (!validationResult.valid) { console.error(validationResult.errors); } - Ensure every flow has exactly one start and one end node
- Check that all nodes are connected in a directed acyclic graph
- Visualize your flow graph to identify structural issues
Step Reference Errors
Symptoms:
- Error message:
Unknown step reference: "stepName" - Flow fails during registration
Causes:
- Referenced step not registered in step registry
- Typo in step reference name
- Step exists but in a different namespace
Solution:
- Verify step registration before flow definition:
import { getStepRegistry } from '@zoopflow/core'; const registry = getStepRegistry(); console.log(registry.listRegisteredSteps()); - Ensure consistent step naming between definition and registration
- Check for namespace prefixes if using namespaced steps
Step Execution Failures
Step Timeouts
Symptoms:
- Error message:
Step execution timeout: "stepName" exceeded 60000ms - Flow stops progressing
Causes:
- Step execution takes longer than configured timeout
- External service calls not completing
- Resource contention or bottlenecks
Solution:
- Increase timeout for specific steps:
defineStep({ name: 'longRunningStep', // ...other config timeout: '5 minutes', // Increase timeout for this step }); - Optimize step implementation for performance
- Implement retry logic for external service calls
- Consider breaking long-running steps into smaller steps
Input/Output Validation Failures
Symptoms:
- Error message:
Schema validation failed: expected string, received number - Step fails during execution
Causes:
- Mismatched input/output types
- Missing required fields
- Invalid data format
Solution:
- Review schema definitions for accuracy
- Add explicit type conversions where needed
- Implement data transformation between incompatible steps
- Use debug mode to inspect input/output at each step:
import { configureDebugger } from '@zoopflow/core'; configureDebugger({ logInputOutput: true, detailedValidation: true, });
Temporal Integration Problems
Workflow Registration Issues
Symptoms:
- Error message:
Failed to register workflow: "flowName" - Worker fails to start
Causes:
- Duplicate workflow registrations
- Incompatible workflow options
- Malformed flow definition
Solution:
- Ensure unique workflow IDs across your application
- Check Temporal worker configuration:
import { Worker } from '@temporalio/worker'; const worker = await Worker.create({ workflowsPath: require.resolve('./workflows'), activities: { /* your activities */ }, taskQueue: 'your-task-queue', }); await worker.run(); - Validate flow definitions before registration
- Check Temporal server logs for detailed error information
Workflow Execution Failures
Symptoms:
- Error message:
Workflow execution failed: NonDeterministicError - Workflows fail unpredictably
Causes:
- Non-deterministic code in workflow implementation
- Temporal version mismatches
- Incorrect workflow versioning
Solution:
- Follow Temporal determinism guidelines:
- Avoid random numbers, current time calls, or non-deterministic operations
- Use Temporal's versioning APIs for workflow changes
- Implement proper versioning for workflows:
import { workflowVersions } from '@zoopflow/core'; // When making changes to existing workflows workflowVersions.setVersion('my-change', 1); - Update Temporal client and worker dependencies
- Implement replay tests for workflows
Schema Validation Errors
Complex Schema Validation Failures
Symptoms:
- Error message:
Validation failed at path: data.nested.property - Validation errors in nested properties
Causes:
- Complex nested schemas
- Dynamic or conditional schemas
- Incorrect schema definitions
Solution:
- Break down complex schemas into smaller, reusable components
- Use schema debugging to inspect validation:
import { setSchemaDebugLevel } from '@zoopflow/core'; setSchemaDebugLevel('verbose'); - Validate inputs before passing to steps:
import { validateAgainstSchema } from '@zoopflow/core'; const validationResult = validateAgainstSchema(inputData, stepSchema); if (!validationResult.valid) { // Handle validation errors } - Use schema coercion for type conversion where appropriate
Custom Validation Errors
Symptoms:
- Error message:
Custom validation failed: "validationName" - Step fails with custom validation error
Causes:
- Custom validator implementation error
- Invalid validation logic
- Missing error handling in custom validators
Solution:
- Debug custom validator implementation:
import { registerCustomValidator } from '@zoopflow/core'; registerCustomValidator('myValidator', (data, params) => { console.log('Validating:', data, 'with params:', params); // Validation logic return true; }); - Test custom validators independently before integration
- Ensure error messages from custom validators are descriptive
- Implement unit tests for custom validators
State Management Issues
State Corruption
Symptoms:
- Unexpected state values
- Workflow produces incorrect results
- Intermittent failures
Causes:
- Direct mutation of state objects
- Missing checkpoint calls
- Race conditions in state updates
Solution:
- Use immutable state patterns:
import { updateState } from '@zoopflow/core'; // Instead of: flowContext.state.value = newValue; updateState(flowContext, 'value', newValue); - Add checkpoints after critical state changes:
import { checkpoint } from '@zoopflow/core'; await updateState(flowContext, 'value', newValue); await checkpoint(flowContext, 'State updated'); - Implement state validation before and after critical operations
- Review state access patterns across async operations
State Persistence Issues
Symptoms:
- Error message:
Failed to persist state: "reason" - State lost between workflow restarts
Causes:
- Storage backend failures
- Serialization errors for complex objects
- Temporal history size limits exceeded
Solution:
- Ensure all state is serializable:
// Check if state is serializable const isSerializable = (obj) => { try { JSON.parse(JSON.stringify(obj)); return true; } catch (e) { return false; } }; - Implement state size monitoring
- Use external state storage for large state objects
- Break up long-running workflows into smaller, chained workflows
Signal Handling Issues
Signal Registration Problems
Symptoms:
- Error message:
Unknown signal: "signalName" - Signals not being processed
Causes:
- Signal not registered with workflow
- Incorrect signal handler implementation
- Signal name mismatches
Solution:
- Verify signal registration:
import { defineSignal } from '@zoopflow/core'; const mySignal = defineSignal({ name: 'processOrder', inputSchema: z.object({ orderId: z.string(), action: z.enum(['approve', 'reject']), }), }); // Register in flow definition defineFlow({ // ... signals: [mySignal], // ... }); - Check signal name consistency between sender and receiver
- Implement signal logging for debugging:
import { configureSignalDebug } from '@zoopflow/core'; configureSignalDebug({ logSignalReceived: true, logSignalHandled: true, });
Signal Handling Failures
Symptoms:
- Error message:
Signal handler exception: "errorMessage" - Signal processed but workflow state not updated
Causes:
- Exceptions in signal handler code
- Race conditions between signals
- State mutation issues in signal handlers
Solution:
- Implement error handling in signal handlers:
import { defineSignalHandler } from '@zoopflow/core'; defineSignalHandler('processOrder', async (payload, context) => { try { // Signal handling code } catch (error) { context.logger.error('Signal handler error', error); // Handle error appropriately } }); - Use workflow mutations for state updates in signal handlers
- Implement signal queuing for concurrent signals
- Add signal validation before processing
Performance Problems
Slow Workflow Execution
Symptoms:
- Workflows take longer than expected
- Increasing latency over time
- Timeouts during execution
Causes:
- Inefficient step implementations
- External service bottlenecks
- Resource constraints
- Large workflow histories
Solution:
- Implement performance monitoring:
import { enablePerformanceTracking } from '@zoopflow/core'; enablePerformanceTracking({ detailedStepMetrics: true, slowStepThreshold: 500, // ms }); - Optimize steps with high execution times
- Implement caching for repeated operations
- Use continuation workflows for long-running processes
- Scale Temporal workers appropriately
Memory Leaks
Symptoms:
- Increasing memory usage over time
- Worker process crashes with out-of-memory errors
- Degrading performance
Causes:
- Accumulating state without cleanup
- Large object retention
- Event listener leaks
Solution:
- Monitor memory usage in workers
- Implement state cleanup for completed workflows
- Use external storage for large data objects
- Properly dispose resources and event listeners
- Implement worker restarts on a schedule
Deployment Problems
Environment Configuration Issues
Symptoms:
- Error message:
Missing configuration: "configName" - Inconsistent behavior between environments
Causes:
- Missing environment variables
- Inconsistent configuration between environments
- Hardcoded development values
Solution:
- Implement configuration validation on startup:
import { validateConfig } from '@zoopflow/core'; const configValidation = validateConfig(process.env); if (!configValidation.valid) { console.error('Invalid configuration:', configValidation.errors); process.exit(1); } - Use configuration schemas to validate environment variables
- Implement environment-specific defaults with override capability
- Document required configuration for each environment
Version Compatibility Issues
Symptoms:
- Error message:
Incompatible version: expected >=2.0.0, got 1.8.0 - Unexpected behavior after updates
Causes:
- Mismatched package versions
- Breaking changes in dependencies
- Incompatible client/worker versions
Solution:
- Lock dependencies with exact versions
- Implement version compatibility checks:
import { checkVersionCompatibility } from '@zoopflow/core'; const compatibility = checkVersionCompatibility(); if (!compatibility.compatible) { console.error('Version incompatibility:', compatibility.issues); } - Test upgrades in isolation before deployment
- Maintain version compatibility matrix documentation
Debugging Techniques
Using Logging Effectively
ZoopFlow provides multi-level logging for troubleshooting:
import { configureLogging } from '@zoopflow/core';
// Configure global logging
configureLogging({
level: 'debug', // 'error', 'warn', 'info', 'debug', 'trace'
format: 'json', // 'text', 'json'
destination: 'console', // 'console', 'file'
filePath: '/var/log/zoopflow.log', // Only if destination is 'file'
includeTimestamp: true,
});Effective logging strategies:
-
Contextual Logging: Include relevant context in logs
context.logger.debug('Processing step', { stepName: step.name, inputSize: JSON.stringify(input).length, flowId: context.flowId, }); -
Correlation IDs: Track requests across components
// In client code const correlationId = generateUUID(); // Pass to context const context = createFlowContext({ correlationId, // other context properties }); // Log with correlation ID context.logger.info('Operation completed', { correlationId }); -
Structured Logging: Use consistent structured format
context.logger.info('Step completed', { step: 'processPayment', duration: 120, status: 'success', metadata: { paymentId: 'pay_123', amount: 100.50, } }); -
Log Levels: Use appropriate levels for different information
- ERROR: Failures requiring immediate attention
- WARN: Issues that don't stop execution but indicate problems
- INFO: Normal operation information
- DEBUG: Detailed information for troubleshooting
- TRACE: Very verbose data for deep debugging
Debugging Flows
-
Flow Visualization: Visualize flow execution paths
import { visualizeFlow } from '@zoopflow/core/debug'; // Generate flow visualization const visualization = visualizeFlow(flowDefinition); // Save visualization to file writeFileSync('flow-visualization.html', visualization); -
Step-by-Step Execution: Enable step-by-step execution mode
import { enableStepByStepExecution } from '@zoopflow/core/debug'; enableStepByStepExecution(flowId, { breakOnSteps: ['criticalStep1', 'criticalStep2'], logStateTransitions: true, }); -
Execution Trace: Capture detailed execution traces
import { captureExecutionTrace } from '@zoopflow/core/debug'; const trace = await captureExecutionTrace(flowId); console.log(JSON.stringify(trace, null, 2)); -
State Snapshots: Capture state at different execution points
import { captureStateSnapshot } from '@zoopflow/core/debug'; // In step implementation const snapshot = await captureStateSnapshot(context); context.logger.debug('State snapshot', { snapshot });
Debugging Steps
-
Step Isolation: Test steps in isolation
import { executeStepInIsolation } from '@zoopflow/core/debug'; const result = await executeStepInIsolation({ step: myStep, input: testInput, mockContext: { // Mock context properties }, }); console.log('Step output:', result); -
Input/Output Inspection: Log input and output
import { logStepIO } from '@zoopflow/core/debug'; logStepIO(stepName, true); // Enable for specific step -
Step Performance Profiling: Profile step execution time
import { profileStep } from '@zoopflow/core/debug'; const profile = await profileStep(stepName, testInput); console.log('Step profile:', profile); -
Mock Dependencies: Test with mocked dependencies
import { mockStepDependencies } from '@zoopflow/core/debug'; mockStepDependencies(myStep, { 'dependencyName': mockImplementation, });
Debugging Schema Validation
-
Schema Visualization: Generate visual representation
import { visualizeSchema } from '@zoopflow/core/debug'; const visualization = visualizeSchema(mySchema); writeFileSync('schema-visualization.html', visualization); -
Validation Tracing: Trace validation steps
import { traceValidation } from '@zoopflow/core/debug'; const trace = traceValidation(data, schema); console.log('Validation trace:', trace); -
Schema Comparison: Compare schemas for compatibility
import { compareSchemas } from '@zoopflow/core/debug'; const comparison = compareSchemas(schemaA, schemaB); console.log('Schema differences:', comparison.differences); -
Test Data Generation: Generate test data from schema
import { generateTestData } from '@zoopflow/core/debug'; const testData = generateTestData(schema); console.log('Test data:', testData);
Remote Debugging
-
Remote Inspector: Connect to running workflows
import { enableRemoteInspector } from '@zoopflow/core/debug'; enableRemoteInspector({ port: 9229, flowId: 'flow-to-debug', }); -
Live State Inspection: Inspect workflow state remotely
import { enableLiveStateInspection } from '@zoopflow/core/debug'; enableLiveStateInspection(workflowId); // Connect with: zoopflow-inspector http://localhost:9229 -
Remote Command Execution: Execute commands in running workflows
import { enableRemoteCommands } from '@zoopflow/core/debug'; enableRemoteCommands({ allowedCommands: ['inspect', 'pause', 'resume'], authToken: 'secure-token', }); -
Distributed Tracing: Implement distributed tracing
import { configureDistributedTracing } from '@zoopflow/core/debug'; configureDistributedTracing({ provider: 'jaeger', endpoint: 'http://jaeger-collector:14268/api/traces', });
Diagnostic Tools and Utilities
ZoopFlow provides several built-in diagnostic tools:
Flow Analyzer
Analyzes flow definitions for potential issues:
import { analyzeFlow } from '@zoopflow/tools';
const analysis = analyzeFlow(flowDefinition);
console.log('Flow analysis:', analysis);The analysis includes:
- Structural validation
- Step dependency checks
- Potential bottlenecks
- Error handling coverage
- Schema compatibility warnings
Performance Monitor
Monitors and reports on flow performance:
import { monitorPerformance } from '@zoopflow/tools';
monitorPerformance({
flowIds: ['flow1', 'flow2'],
metrics: ['executionTime', 'stateSize', 'stepLatency'],
interval: 60000, // 1 minute
callback: (metrics) => {
console.log('Performance metrics:', metrics);
},
});Workflow Replay Tool
Replays workflows from history for debugging:
import { replayWorkflow } from '@zoopflow/tools';
const replay = await replayWorkflow(workflowId, {
stopAtFailure: true,
detailedStateTracking: true,
});
console.log('Replay results:', replay);Schema Inspector
Analyzes schema definitions:
import { inspectSchema } from '@zoopflow/tools';
const inspection = inspectSchema(schemaDefinition);
console.log('Schema inspection:', inspection);The inspection includes:
- Validation rules
- Required vs optional fields
- Type constraints
- Custom validators
- Potential validation issues
Performance Tuning and Optimization
Workflow Optimization
-
State Size Reduction:
- Keep state minimal by storing only essential data
- Use external storage for large objects
- Implement state cleanup for completed steps
import { optimizeState } from '@zoopflow/core/performance'; optimizeState(flowContext); -
Step Parallelization:
- Identify and parallelize independent steps
- Use parallel execution patterns for suitable tasks
import { parallel } from '@zoopflow/core'; await parallel([ () => executeStep1(input1), () => executeStep2(input2), () => executeStep3(input3), ]); -
Caching Strategies:
- Implement caching for repeated operations
- Cache external service responses
import { enableCaching } from '@zoopflow/core/performance'; enableCaching({ ttl: 300, // seconds maxSize: 100, // entries }); -
Workflow Splitting:
- Split large workflows into child workflows
- Implement continuation-based workflows for long-running processes
import { continueAsNew } from '@zoopflow/core'; if (isWorkflowTooLarge(context)) { await continueAsNew(context, remainingSteps); }
Worker Optimization
-
Worker Scaling:
- Scale workers based on queue depth
- Implement worker auto-scaling
import { configureWorkerScaling } from '@zoopflow/core/performance'; configureWorkerScaling({ minWorkers: 5, maxWorkers: 50, targetQueueDepth: 10, }); -
Resource Allocation:
- Allocate resources based on workflow complexity
- Implement worker resource limits
import { configureWorkerResources } from '@zoopflow/core/performance'; configureWorkerResources({ memoryLimit: '1Gi', cpuLimit: '500m', }); -
Connection Pooling:
- Implement connection pooling for external services
- Reuse connections where possible
import { configureConnectionPool } from '@zoopflow/core/performance'; configureConnectionPool({ service: 'database', maxConnections: 20, idleTimeout: 10000, }); -
Batch Processing:
- Implement batch processing for similar operations
- Group external service calls
import { batchProcess } from '@zoopflow/core/performance'; await batchProcess(items, processItem, { batchSize: 100, concurrency: 5, });
Recovery Strategies
Flow Recovery
-
Checkpoint Recovery:
- Implement regular checkpoints in workflows
- Recover from last checkpoint on failure
import { createCheckpoint, recoverFromCheckpoint } from '@zoopflow/core'; // Create checkpoint await createCheckpoint(context, 'after-payment-processing'); // Recover from checkpoint if (isRecoveryNeeded) { await recoverFromCheckpoint(context, 'after-payment-processing'); } -
Step Retry Strategies:
- Configure retry policies for steps
- Implement exponential backoff
import { configureRetryPolicy } from '@zoopflow/core'; configureRetryPolicy('processPayment', { maxAttempts: 5, initialInterval: 1000, backoffCoefficient: 2, maximumInterval: 60000, }); -
Compensation Transactions:
- Implement compensation for failed operations
- Rollback changes on failure
import { registerCompensation } from '@zoopflow/core'; // Register compensation registerCompensation(context, 'processPayment', async () => { await refundPayment(paymentId); }); // Execute compensations if needed if (flowFailed) { await executeCompensations(context); } -
State Recovery:
- Implement state backup and recovery
- Recover from state snapshots
import { backupState, recoverState } from '@zoopflow/core'; // Backup state await backupState(context); // Recover state if needed if (stateCorrupted) { await recoverState(context); }
System Recovery
-
Worker Recovery:
- Implement worker health checks
- Auto-restart failed workers
import { configureWorkerRecovery } from '@zoopflow/core'; configureWorkerRecovery({ healthCheckInterval: 30000, autoRestart: true, maxRestarts: 5, }); -
Disaster Recovery:
- Implement multi-region deployment
- Configure failover procedures
import { configureDisasterRecovery } from '@zoopflow/core'; configureDisasterRecovery({ regions: ['us-east-1', 'us-west-2'], failoverThreshold: 3, dataReplication: true, }); -
Data Recovery:
- Implement state backup and recovery
- Configure data backup schedules
import { configureDataBackup } from '@zoopflow/core'; configureDataBackup({ schedule: '0 0 * * *', // Daily at midnight retention: 7, // days location: 's3://backup-bucket/zoopflow', });
How to Get Help and Report Issues
Community Resources
-
GitHub Issues: Report bugs and feature requests
- https://github.com/zoopflow/core/issues (opens in a new tab)
- Use issue templates for different types of problems
-
Documentation: Comprehensive guides and reference
-
Community Forum: Ask questions and share knowledge
-
Slack Channel: Real-time community support
Reporting Issues Effectively
When reporting issues, include:
-
Environment Information:
ZoopFlow Version: x.y.z Temporal Version: a.b.c Node.js Version: d.e.f OS: Windows/macOS/Linux -
Reproduction Steps:
- Clear steps to reproduce the issue
- Minimal code example if possible
-
Actual vs Expected Behavior:
- What happened
- What you expected to happen
-
Logs and Error Messages:
- Relevant logs with appropriate log level
- Complete error stack traces
-
Context:
- When did the issue start occurring
- Any recent changes to your system
Support Channels
-
Professional Support: For enterprise customers
- Email: support@zoopflow.io
- Support portal: https://support.zoopflow.io (opens in a new tab)
-
Office Hours: Weekly technical office hours
- Schedule: Every Thursday at 11am PT
- Registration: https://zoopflow.io/office-hours (opens in a new tab)
Troubleshooting Checklist
Use this checklist as a systematic approach to troubleshooting:
Initial Assessment
- Identify the specific error message or symptom
- Determine which component is failing (flow, step, schema, signals, etc.)
- Review recent changes that might have introduced the issue
- Check environment configuration for misconfigurations
Data Collection
- Gather logs at appropriate detail level
- Capture error stack traces
- Record reproduction steps
- Identify patterns (intermittent vs consistent, specific conditions)
Analysis
- Review flow definition for structural issues
- Validate schemas against actual data
- Check step implementations for logical errors
- Verify Temporal configuration
- Test signal handlers in isolation
Resolution Steps
- Implement targeted fixes based on root cause
- Test in isolation before full system testing
- Validate fix with original reproduction steps
- Update documentation if issue relates to undocumented behavior
- Add regression tests to prevent recurrence
Prevention
- Update monitoring to detect similar issues
- Share learnings with team members
- Implement safeguards against similar issues
- Review error handling in related components
By following this guide, you should be able to diagnose and resolve most issues encountered when working with ZoopFlow. If you still face challenges after trying these solutions, reach out to the community or support channels for additional assistance.