Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ran into an issue with a recurring instance of later.js #85

Closed
ivorpad opened this issue Feb 4, 2021 · 2 comments
Closed

Ran into an issue with a recurring instance of later.js #85

ivorpad opened this issue Feb 4, 2021 · 2 comments

Comments

@ivorpad
Copy link

ivorpad commented Feb 4, 2021

This doesn't work as expected or am I doing something wrong?:

interval: later.parse.recur().on("12:10").time(),

Got this error:

internal/worker.js:210
    this[kPort].postMessage({
                ^

DOMException [DataCloneError]: function on() {
      values = Array.isArray(arguments[0]) ? arguments[0] : arguments;
      return this;
    } could not be cloned.
    at new Worker (internal/worker.js:210:17)
    at Bree.run (/Users/ivor/Developer/projects/order-tracking-app/ezot-jobs-server/node_modules/bree/lib/index.js:275:30)
    at /Users/ivor/Developer/projects/order-tracking-app/ezot-jobs-server/node_modules/bree/lib/index.js:460:27
    at Timeout.scheduleTimeout [as _onTimeout] (/Users/ivor/Developer/projects/order-tracking-app/ezot-jobs-server/node_modules/@breejs/later/lib/index.js:1013:7)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1

It works perfectly with later.parse.text but I need the job to ocurr at a certain date after the created_at field in the database. Basically:

const date = new Date(job.created_at);
const hour = date.getUTCHours();
const minute = date.getUTCMinutes();
const seconds = date.getUTCSeconds();
later.parse.recur().on(`${hour}:${minute}:${seconds}`).time().on(getDay(date)).dayOfMonth();
@ivorpad
Copy link
Author

ivorpad commented Feb 4, 2021

Alright, so it seems you need to pass an object to interval:

 const everyThirtyDays = later.parse.recur().every(20).second();
 interval: { schedules: everyTwentySeconds.schedules }

@shadowgate15
Copy link
Member

Looks like you solved it yourself, @ivorpad. Let us know if you need anymore help with this but will close it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants