Learn about error handling and retries in Schedo.dev
schedo.defineJob( 'example-job', '* * * * *', async (ctx) => { try { await riskyOperation(); } catch (error) { // Rethrow to trigger retry mechanism throw error; } } );
schedo.defineJob( 'retry-example', '0 * * * *', async (ctx) => { // Job implementation }, { // Retry configuration retries: 3, // Number of retry attempts retryDelay: 60000, // Delay between retries (ms) } );
schedo.defineJob( 'context-example', '0 * * * *', async (ctx) => { try { await operation(); } catch (error) { // Access execution context console.log('Job failed:', { jobCode: ctx.jobCode, executionId: ctx.executionId, attempt: ctx.attempt }); throw error; } } );
async (ctx) => { try { await operation(); } catch (error) { if (isTransientError(error)) { throw error; // Let Schedo handle retries } else { // Handle non-retryable errors console.error('Permanent failure:', error); throw error; } } }
async (ctx) => { let resource; try { resource = await allocateResource(); await useResource(resource); } catch (error) { throw error; } finally { if (resource) { await releaseResource(resource); } } }