Skip to content

[twenties] Fix TypeError on scheduling for the next day#4236

Merged
thyttan merged 2 commits into
espruino:masterfrom
elfehr:master
Jun 1, 2026
Merged

[twenties] Fix TypeError on scheduling for the next day#4236
thyttan merged 2 commits into
espruino:masterfrom
elfehr:master

Conversation

@elfehr
Copy link
Copy Markdown

@elfehr elfehr commented Jun 1, 2026

Twenties v0.06 introduced a bug that prevents it to set a timer for the next work day.
This error message appears in the IDE after the last buzz of the day:

Uncaught TypeError: Variables of type Object are not supported in date constructor
    at .boot0:52:38
            const next = new Date(now);

@thyttan
Copy link
Copy Markdown
Collaborator

thyttan commented Jun 1, 2026

Thanks! I presume this is tested and works well?

@thyttan thyttan merged commit 930a136 into espruino:master Jun 1, 2026
@elfehr
Copy link
Copy Markdown
Author

elfehr commented Jun 1, 2026

Thank!
The error message is gone, but now I wonder if I haven't found another bug.
next is set to today 8am, which is included in work time, so the date is not incremented. With print statements in the IDE, I see that next - now is negative, setTimeout(scheduleNext, next - now) seems to timeout immediately, and the function is called constantly.

@thyttan
Copy link
Copy Markdown
Collaborator

thyttan commented Jun 1, 2026

Hm. Since I'm refactoring twenties to use the scheduling library anyways would you mind trying out that one instead: #4231

@elfehr
Copy link
Copy Markdown
Author

elfehr commented Jun 1, 2026

Alright, having a look now.

Otherwise, Date(now+864e5) (now+24h) seems to fix it, and for some reason it doesn't trigger the same TypeError as Date(now) does.

@thyttan
Copy link
Copy Markdown
Collaborator

thyttan commented Jun 1, 2026

Feel free to open another PR if you want 🙂

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

Successfully merging this pull request may close these issues.

2 participants