Error and Logging
Whenever Sidetrack encounters an unhandled exception while running your job, the error and stack trace will be appended to the errors
field for that job, and the job will be marked as failed (or retrying if more attempts are available).
While you can always refer to the errors
field on the job to see what went wrong, you should consider adding logs.
ts
import {Sidetrack ,SidetrackJobWithPayload } from "sidetrack";constonboardUser = async (job :SidetrackJobWithPayload <{try {// do something} catch (error ) {logger .error (`Job ${job .id } failed`,error );throwerror ;}};constsidetrack = newSidetrack <{userOnboarding : {}>({databaseOptions : {connectionString :process .env ["DATABASE_URL"]!,},queues : {userOnboarding : {handler :onboardUser ,},},});
ts
import {Sidetrack ,SidetrackJobWithPayload } from "sidetrack";constonboardUser = async (job :SidetrackJobWithPayload <{try {// do something} catch (error ) {logger .error (`Job ${job .id } failed`,error );throwerror ;}};constsidetrack = newSidetrack <{userOnboarding : {}>({databaseOptions : {connectionString :process .env ["DATABASE_URL"]!,},queues : {userOnboarding : {handler :onboardUser ,},},});