Hosted cron job service. Schedule HTTP requests on a cron, after a delay or right away. Every run logged, failed jobs retried, alerts by email or Slack.
The setUTCHours plus setDate mix worries me more than the + 1, because the same build deletes on a different day depending on the container's TZ. Did the merged fix switch to setUTCDate(getUTCDate() - days), or does it still rely on the server running in UTC?
It's fully UTC now. The merged fix replaced it with new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - trashRetentionDays)), so the container's TZ no longer matters. It also dropped the + 1 and added a unit test for the 23:50 case.
Solo developer building practical CLI tools for Linux auditing and B2B data extraction. Creator of Vaultcheck and NPILift. I write about silent failures, false green lights, and infrastructure reliabi
A count assertion cannot catch the day-early delete: one record too many and one too few and the number still matches. Assert the set instead — DELETE ... RETURNING id and diff it against the expected id list — so the boundary record shows up as a diff rather than a total that happens to be right.
Good point. With a batch of records spread across multiple days, a shifted window could delete one record too early and retain another too long while still passing a COUNT(*) check.
In the Twenty scenario, we tested specific boundary records: one soft-deleted at 00:05 and another at 23:50 for 14-day retention, plus a 23:59 record for 1-day retention. After each 00:10 cron run, we checked whether those specific records survived rather than relying on an aggregate table count.
For larger multi-record or cohort scenarios, asserting the exact surviving ID set (SELECT id ... ORDER BY id) is definitely the safer pattern.
Since ChronoStack runs against the unmodified published Docker image (twentycrm/twenty:v2.58.0), we can't rewrite Twenty's internal DELETE statement to use RETURNING id. Comparing the remaining ID set externally is the closest equivalent.
Thanks for suggesting the stronger assertion pattern!
Solo developer building practical CLI tools for Linux auditing and B2B data extraction. Creator of Vaultcheck and NPILift. I write about silent failures, false green lights, and infrastructure reliabi
External set comparison beats the count, but only as an exact set: diff two sorted id lists and treat any line as a failure, not a length match. The digest matters more than the tag here — the retention window lives inside the image, so twentycrm/twenty@sha256:... is what makes the assertion still mean something next quarter.
Agreed on both. An exact diff of sorted IDs is the right assertion: any line in the diff is a failure. And the digest point is a good one. The retention logic lives in the image, so twenty@sha256:… is what keeps the scenario meaning the same thing later. A tag can move under you.
Exactly. That one cost me the most time: no error, nothing in the logs, the job just never ran. pg_cron (like Vixie cron) treats a jump of more than 3 hours as a clock change and skips the missed runs instead of catching up. ChronoStack works around it by stopping the clock on each job's minute, and advance --dry-run shows which jobs will run, so a skipped run at least becomes visible.
Both. For a job with a fixed time (say 0 3 * * ), it plans a clock stop on that job's minute, so it doesn't get skipped, and the dry run lists it at each stop. Jobs like * * * * * or */5 * * * * are the tricky ones: stopping on every minute of a 30-day jump would mean 43,200 stops. pg_cron runs a wildcard job once per stop, so the dry run flags the gap:
pg_cron: job '/5 * * * *' is due 8640 time(s) but will run about 30 (... use --pg-cron-all or --step to run more)
--pg-cron-all stops on every occurrence, up to a limit of 2,000 stops. --step 1h is a cheaper middle ground. --dry-run --json has the same numbers under pg_cron_wildcards, so CI can fail on them.
--step 1h as the middle ground makes sense, and pg_cron_wildcards under --dry-run --json means CI can catch it instead of someone noticing a month later.
That's the idea. If you have a stack with pg_cron, I'd be curious what the dry run says about it. Wildcard schedules turn up more often than you'd expect.
Custom software & AI development company. We build production-ready AI integrations, mobile apps, and web platforms for businesses that want real results. lycore.com
The mix of setUTCHours with local-time setDate/getDate is a subtle one, and it's a good illustration of why mocking new Date() hides this class of bug. A cheap extra safeguard is to run the cleanup comparison in SQL against now() with an interval, so the boundary lives in one place and uses the database clock. It would also be worth a test that runs the job under two different TZ settings. How does your tool handle jobs that depend on both the DB clock and the app server clock?
Thanks, good points on both. On your question: that's the case it's built for. The database and the app containers read the same virtual clock (the shim is loaded into every service in the stack), so a job comparing Postgres now() with the app's new Date() sees the same moment on both sides, and chronostack doctor / probe check that every service agrees. Two exceptions: Go and other static binaries can't be shimmed (doctor flags them), and monotonic clocks are deliberately left alone. ChronoStack doesn't change time zones itself, but your two-TZ idea works well with it: run the same scenario twice with a different TZ in a compose override and compare the runs with chronostack report diff.
Custom software & AI development company. We build production-ready AI integrations, mobile apps, and web platforms for businesses that want real results. lycore.com
That's useful, thanks. Having Postgres now() and the app clock read the same virtual time is exactly what makes these boundary bugs reproducible. Running the same scenario under two TZ values and diffing the reports sounds like a cheap way to catch the setUTCHours vs local-time class of issue, so I'll try that.
That's exactly the kind of scenario I'd love ChronoStack to make easier to reproduce. Would be interesting to see what differences show up between the two TZ configurations, especially around date boundaries and DST transitions.
If you get a chance to try it and find it useful, a GitHub star would certainly help the project reach more developers. Either way, I'd genuinely appreciate any feedback from your testing!
A retention window that is a day short only shows up if someone waits two weeks and deletes at the right minute, which is exactly why it survived. Renhua's point about asserting the exact set of deleted ids rather than a count is the test I would copy first.
Ascendra Ventures built CleanSync, which keeps Google Drive in two-way sync with a server you own, around the same worry that a cleanup job can remove the wrong thing quietly. Every sync is rehearsed as a dry run first. If a run would delete more files than your limit, it stops and shows the list instead of proceeding. Anything replaced or deleted goes to a Recovery folder before it is gone, so a boundary bug costs a restore rather than a record.
Did the Twenty maintainers discuss a second safety stage like that, or is the 14 day trash itself considered the safety net?
As far as I saw, no. The fix was scoped to the cutoff calculation, and the 14-day trash is the safety net. That's also why the bug mattered: the safety net was itself a day short. A dry run or a cap on deletions per run would be a sensible second layer, but that's a design change for the maintainers rather than part of this fix.
We're a place where coders share, stay up-to-date and grow their careers.
The
setUTCHoursplussetDatemix worries me more than the+ 1, because the same build deletes on a different day depending on the container's TZ. Did the merged fix switch tosetUTCDate(getUTCDate() - days), or does it still rely on the server running in UTC?It's fully UTC now. The merged fix replaced it with new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - trashRetentionDays)), so the container's TZ no longer matters. It also dropped the + 1 and added a unit test for the 23:50 case.
A count assertion cannot catch the day-early delete: one record too many and one too few and the number still matches. Assert the set instead — DELETE ... RETURNING id and diff it against the expected id list — so the boundary record shows up as a diff rather than a total that happens to be right.
Good point. With a batch of records spread across multiple days, a shifted window could delete one record too early and retain another too long while still passing a
COUNT(*)check.In the Twenty scenario, we tested specific boundary records: one soft-deleted at
00:05and another at23:50for 14-day retention, plus a23:59record for 1-day retention. After each00:10cron run, we checked whether those specific records survived rather than relying on an aggregate table count.For larger multi-record or cohort scenarios, asserting the exact surviving ID set (
SELECT id ... ORDER BY id) is definitely the safer pattern.Since ChronoStack runs against the unmodified published Docker image (
twentycrm/twenty:v2.58.0), we can't rewrite Twenty's internalDELETEstatement to useRETURNING id. Comparing the remaining ID set externally is the closest equivalent.Thanks for suggesting the stronger assertion pattern!
External set comparison beats the count, but only as an exact set: diff two sorted id lists and treat any line as a failure, not a length match. The digest matters more than the tag here — the retention window lives inside the image, so twentycrm/twenty@sha256:... is what makes the assertion still mean something next quarter.
Agreed on both. An exact diff of sorted IDs is the right assertion: any line in the diff is a failure. And the digest point is a good one. The retention logic lives in the image, so twenty@sha256:… is what keeps the scenario meaning the same thing later. A tag can move under you.
pg_cron skipping jobs after a jump of more than 3 hours is the quiet failure here. the off-by-one is easy to spot, the skipped run is not.
Exactly. That one cost me the most time: no error, nothing in the logs, the job just never ran. pg_cron (like Vixie cron) treats a jump of more than 3 hours as a clock change and skips the missed runs instead of catching up. ChronoStack works around it by stopping the clock on each job's minute, and advance --dry-run shows which jobs will run, so a skipped run at least becomes visible.
advance --dry-run making the skipped run visible is the real fix here. does it flag the ones that would have been skipped, or just list what will run?
Both. For a job with a fixed time (say 0 3 * * ), it plans a clock stop on that job's minute, so it doesn't get skipped, and the dry run lists it at each stop. Jobs like * * * * * or */5 * * * * are the tricky ones: stopping on every minute of a 30-day jump would mean 43,200 stops. pg_cron runs a wildcard job once per stop, so the dry run flags the gap:
pg_cron: job '/5 * * * *' is due 8640 time(s) but will run about 30 (... use --pg-cron-all or --step to run more)
--pg-cron-all stops on every occurrence, up to a limit of 2,000 stops. --step 1h is a cheaper middle ground. --dry-run --json has the same numbers under pg_cron_wildcards, so CI can fail on them.
--step 1h as the middle ground makes sense, and pg_cron_wildcards under --dry-run --json means CI can catch it instead of someone noticing a month later.
That's the idea. If you have a stack with pg_cron, I'd be curious what the dry run says about it. Wildcard schedules turn up more often than you'd expect.
The mix of setUTCHours with local-time setDate/getDate is a subtle one, and it's a good illustration of why mocking new Date() hides this class of bug. A cheap extra safeguard is to run the cleanup comparison in SQL against now() with an interval, so the boundary lives in one place and uses the database clock. It would also be worth a test that runs the job under two different TZ settings. How does your tool handle jobs that depend on both the DB clock and the app server clock?
Thanks, good points on both. On your question: that's the case it's built for. The database and the app containers read the same virtual clock (the shim is loaded into every service in the stack), so a job comparing Postgres now() with the app's new Date() sees the same moment on both sides, and chronostack doctor / probe check that every service agrees. Two exceptions: Go and other static binaries can't be shimmed (doctor flags them), and monotonic clocks are deliberately left alone. ChronoStack doesn't change time zones itself, but your two-TZ idea works well with it: run the same scenario twice with a different TZ in a compose override and compare the runs with chronostack report diff.
That's useful, thanks. Having Postgres now() and the app clock read the same virtual time is exactly what makes these boundary bugs reproducible. Running the same scenario under two TZ values and diffing the reports sounds like a cheap way to catch the setUTCHours vs local-time class of issue, so I'll try that.
That's exactly the kind of scenario I'd love ChronoStack to make easier to reproduce. Would be interesting to see what differences show up between the two TZ configurations, especially around date boundaries and DST transitions.
If you get a chance to try it and find it useful, a GitHub star would certainly help the project reach more developers. Either way, I'd genuinely appreciate any feedback from your testing!
A retention window that is a day short only shows up if someone waits two weeks and deletes at the right minute, which is exactly why it survived. Renhua's point about asserting the exact set of deleted ids rather than a count is the test I would copy first.
Ascendra Ventures built CleanSync, which keeps Google Drive in two-way sync with a server you own, around the same worry that a cleanup job can remove the wrong thing quietly. Every sync is rehearsed as a dry run first. If a run would delete more files than your limit, it stops and shows the list instead of proceeding. Anything replaced or deleted goes to a Recovery folder before it is gone, so a boundary bug costs a restore rather than a record.
Did the Twenty maintainers discuss a second safety stage like that, or is the 14 day trash itself considered the safety net?
As far as I saw, no. The fix was scoped to the cutoff calculation, and the 14-day trash is the safety net. That's also why the bug mattered: the safety net was itself a day short. A dry run or a cap on deletions per run would be a sensible second layer, but that's a design change for the maintainers rather than part of this fix.