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

Getting error date.format is not a function #636

Closed
tbhaxor opened this issue Dec 2, 2022 · 11 comments
Closed

Getting error date.format is not a function #636

tbhaxor opened this issue Dec 2, 2022 · 11 comments

Comments

@tbhaxor
Copy link

tbhaxor commented Dec 2, 2022

Description

I am getting the following error in the version v2.0.0

https://github.com/kelektiv/node-cron/blob/master/lib/time.js#L271

Cron expression I am using

CronExpression.EVERY_MINUTE

Screenshots

Screenshot_20221202_082404

Additional information

No response

@radcapitalist
Copy link

radcapitalist commented Dec 7, 2022

Same problem here. I'm at version 2.1.0. The crash is in this code here:

				// hard stop if the current date is after the expected execution
				if (Date.now() > timeout) {
					throw new Error(
						Something went wrong. It took over five seconds to find the next execution time for the cron job.
							Please refer to the canonical issue (https://github.com/kelektiv/node-cron/issues/467) and provide the following string if you would like to help debug:
							Time Zone: ${zone || '""'} - Cron String: ${this} - UTC offset: ${date.format(
							'Z'
						)} - current Date: ${luxon.DateTime.local().toString()}`
					);
				}

Curious, @tbhaxor , if this happens every time for you or intermittently. For me, I'm getting this intermittently when running my unit tests when I ask for a bunch of next dates. I'll keep investigating.

Eric

@ChrisTolmeijer
Copy link

Running into this issue too. Programmatically starting a cron with 0 */5 * * * * as interval.
Screen Shot 2022-12-24 at 3 37 37 PM

For me it happens randomly so far. Need to catch this anyhow since it's apparently happening when it's already about to throw an exception. However, maybe the fact that this error is happening generating the error message is indicative of another underlying problem.

@lk77
Copy link

lk77 commented Dec 26, 2022

i have the same issue it seems, and it's pretty random too

file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js TypeError: n.format is not a function
    at l._getNextDateFrom (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:258591)
    at l.sendAt (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:257749)
    at n.nextDates (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:255002)
    at t.startTask (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:106681)
    at t.addGlobalTasks (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:105620)
    at new t (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:105351)
    at t.mounted (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:107997)
    at s.e.init (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:99153)
    at Sr.<anonymous> (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:207994)
    at Array.<anonymous> (file:///storage/emulated/0/app/18d69ebda12db328db91.bundle.js:2:12362),vue-component-5-e,nextTick

@tbhaxor

This comment was marked as off-topic.

@tbhaxor tbhaxor closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2023
@intcreator intcreator reopened this Feb 16, 2023
@intcreator
Copy link
Collaborator

this is fixed in #630

@barisusakli
Copy link

Will there be a 2.2.1 with this fix?

@intcreator
Copy link
Collaborator

yeah, working on publishing to NPM. might be a 2.3.0 though since we've changed some heavier stuff as well

@ledlamp
Copy link

ledlamp commented Mar 5, 2023

@barisusakli wow, my nodebb forum also broken as of 12h ago with this error. i wonder what happened! this code looks strange 🤨

node-cron/lib/time.js

Lines 262 to 278 in 03f94ad

// it shouldn't take more than 5 seconds to find the next execution time
// being very generous with this. Throw error if it takes too long to find the next time to protect from
// infinite loop.
var timeout = Date.now() + 5000;
// determine next date
while (true) {
var diff = date - start;
// hard stop if the current date is after the expected execution
if (Date.now() > timeout) {
throw new Error(
`Something went wrong. It took over five seconds to find the next execution time for the cron job.
Please refer to the canonical issue (https://github.com/kelektiv/node-cron/issues/467) and provide the following string if you would like to help debug:
Time Zone: ${zone || '""'} - Cron String: ${this} - UTC offset: ${date.offset}
- current Date: ${luxon.DateTime.local().toString()}`
);
}

and #630 doesn't solve anything, it's still gonna throw the error ☹️ #408 #467 looks like it's been around for years and nobody knows what's wrong? 😦

@intcreator
Copy link
Collaborator

@ledlamp #467 is a pretty general error which can have a number of causes. basically any time the CPU lags too much the error can be thrown. this can be due to infinite loops, overloaded systems, etc. honestly we should close that issue and focus on issues that have specific causes. no program is perfect so it's unreasonable to expect that it will absolutely never fail

HonmaMeikodesu added a commit to HonmaMeikodesu/goods_hunter that referenced this issue Nov 25, 2023
@cryptomaxsun

This comment was marked as off-topic.

@ledlamp
Copy link

ledlamp commented Nov 14, 2024

@ledlamp #467 is a pretty general error which can have a number of causes. basically any time the CPU lags too much the error can be thrown. this can be due to infinite loops, overloaded systems, etc. honestly we should close that issue and focus on issues that have specific causes. no program is perfect so it's unreasonable to expect that it will absolutely never fail

issue was #638 fixed in #639

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

8 participants