Title: fix(cron): bind stale async-job cutoffs through the column encoder by waleedlatif1 · Pull Request #6327 · simstudioai/sim · GitHub
Open Graph Title: fix(cron): bind stale async-job cutoffs through the column encoder by waleedlatif1 · Pull Request #6327 · simstudioai/sim
X Title: fix(cron): bind stale async-job cutoffs through the column encoder by waleedlatif1 · Pull Request #6327 · simstudioai/sim
Description: Summary The stale-processing predicate in cleanup-stale-executions interpolated Date values directly into a raw sql template. A raw template carries no column context, so drizzle skips PgTimestamp.mapToDriverValue (which stringifies via toISOString) and postgres-js receives a Date it cannot serialize under the pools' prepare: false / fetch_types: false options Bind both cutoffs with sql.param(date, column), matching the workflow sweep already doing this on line 153 of the same handler The testing sql mock already rejected sql.param(date) for exactly this reason but not the interpolated form that shipped — extended it to cover both Evidence Every run of the job has failed its async-job sweep since v0.7.59, while the surrounding typed lt(column, date) sweeps in the same request succeed: 10:00:35.240 Stale execution cleanup completed <- lt(column, date) OK 10:00:35.287 Failed to clean up stale async jobs <- raw sql`…${date}` FAIL 10:00:35.431 Deleted 57 old async jobs <- lt(column, date) OK New: zero CleanupStaleExecutions errors in 7 days of logs before today; first at 09:00:35 UTC, the first run after the release cut over at 08:42:45 Deterministic: 4/4 invocations since onset failed, every one immediately after its Starting stale execution cleanup job line Not data or environment: the identical predicate returns cleanly when run read-only with now() substituted; async_jobs has zero processing rows Impact: stuck async jobs are never reaped, so job slots leak and executions stay running indefinitely. Type of Change Bug fix Testing bunx vitest run app/api/cron — 15 passing. Reverting the fix with the mock guard in place fails 3 existing tests, so the regression is covered without new test code. Full suite (20,200 tests) shows no other route binding a bare Date into a sql template; the 5 unrelated failures reproduce on clean origin/staging. Lint 23/23 and typecheck clean. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA) ⚠️ Correction (post-merge) Independent verification after merge found two errors in the description above. The fix itself is correct and confirmed (reproduced locally against the real stack), but the recorded rationale is wrong: The stated mechanism is wrong. This is not caused by the pools' prepare: false / fetch_types: false options — a 2×2 matrix test proved those are irrelevant. The actual cause is drizzle() overwriting client.options.serializers for temporal OIDs. The sql.param(date, column) fix is still the right one; only the explanation was incorrect. The fix is incomplete, and the mock guard does not prove otherwise. Five further live instances of the same bug exist, one introduced in the same commit and release as the site fixed here. The claim that the full suite proved no other instances is false: the database.mock.ts guard only fires on paths tests actually execute, and 26 test files override the drizzle-orm mock — two of the missed sites have passing tests. Realized production impact was effectively zero. No jobs happened to get stuck during the ~9.5-hour window. The bug was real and deterministic, but caused no measurable harm. A follow-up PR addresses the remaining instances, corrects the misleading comment in packages/testing/src/mocks/database.mock.ts, and replaces the mock guard with a repo-wide detector that covers untested and mock-overriding code.
Open Graph Description: Summary The stale-processing predicate in cleanup-stale-executions interpolated Date values directly into a raw sql template. A raw template carries no column context, so drizzle skips PgTimestamp...
X Description: Summary The stale-processing predicate in cleanup-stale-executions interpolated Date values directly into a raw sql template. A raw template carries no column context, so drizzle skips PgTimestamp...
Opengraph URL: https://github.com/simstudioai/sim/pull/6327
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:24d295bf-b3f2-e6d1-39f1-bd8ce6702f78 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A968:2C34A2:2754B3:371D03:6AFB528B |
| html-safe-nonce | bc9cf8d33404e2674f6464bc98668c907412521efad35fcd91f4a3e9460af212 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTY4OjJDMzRBMjoyNzU0QjM6MzcxRDAzOjZBRkI1MjhCIiwidmlzaXRvcl9pZCI6IjcxODM4ODk1OTEwMzAyMDcxMTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 43dc35b133b8b8770a4c46d88f6b39f3db34ddd2642552e1073dff0c1590be0a |
| hovercard-subject-tag | pull_request:4220256849 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6327/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary The stale-processing predicate in cleanup-stale-executions interpolated Date values directly into a raw sql template. A raw template carries no column context, so drizzle skips PgTimestamp... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width