kibertoad / toad-scheduler

In-memory Node.js and browser job scheduler
MIT License
564 stars 25 forks source link

stop() can throw undefined errors #199

Open mattbishop opened 1 year ago

mattbishop commented 1 year ago

I am closing a toad scheduler instance using a shutdown hook and I often see this error when the hook calls stop():

Cannot read properties of undefined (reading 'engines')
    err: {
      "type": "TypeError",
      "message": "Cannot read properties of undefined (reading 'engines')",
      "stack":
          TypeError: Cannot read properties of undefined (reading 'engines')
              at stop (/Users/matt/Projects/monorepo/node_modules/toad-scheduler/dist/lib/toadScheduler.js:40:49)
              at fn (file:///Users/matt/Projects/monorepo/admin-api/src/shutdown.ts:8:36)
              at async run (/Users/matt/monorepo/node_modules/close-with-grace/index.js:92:19)
    }

Not sure what is happening exactly, but a bit more defensiveness with checking for engines !== undefined would help the close() function.

kibertoad commented 1 year ago

thank you for the report! will take a look