Pulse
GithubCloud(Pulsecron)
  • What is Pulse?
  • Why Pulse?
  • Quick Start
  • DOCS
    • Setup & Config
      • Connection
      • Config
        • Name
        • ProcessEvery
        • DefaultConcurrency
        • MaxConcurrency
        • LockLimit
        • DefaultLockLimit
        • DefaultLockLifetime
        • Sort
        • ResumeOnRestart
    • Defining Job Processors
    • Managing Job Processor
      • Start
      • Stop
    • Creating Jobs
      • Every
      • Schedule
      • Now
      • Create
    • Managing Jobs
      • Jobs
      • Cancel
      • Disable
      • Enable
      • Purge
      • isRunning
      • isExpired
      • Manually working
        • Save
        • Unique
        • RepeatEvery
        • RepeatAt
        • Schedule
        • Remove
        • Priority
        • Touch
        • SetShouldSaveResult
        • Fail
        • Run
        • Disable
        • Enable
Powered by GitBook
On this page
  • job.fail()
  • Example Usage
  • Parameters
  • Returns

Was this helpful?

Edit on GitHub
  1. DOCS
  2. Managing Jobs
  3. Manually working

Fail

PreviousSetShouldSaveResultNextRun

Last updated 1 year ago

Was this helpful?

job.fail()

The fail method marks a job as failed and updates its attributes accordingly. It records the reason for failure, increments the failure count, and, if the job configuration permits, schedules the job for a retry based on the specified backoff strategy. This does NOT save the job in the database. you must explicitly declare if you want to save it

Example Usage

const job = pulse.create('test', {});
job.fail(new Error('Unable to connect to database'));
job.save(); // If you want to save it

Parameters

  • reason (string | Error): The reason for the job's failure, which can be provided as either a string or an Error object. If an Error object is provided, its message is used as the failure reason.

Returns

  • Job: Returns the job instance, allowing for method chaining.

save()