Your database is lying to you about time
Ian Macartney, who built a bunch of our components (Workpool, Workflow, Rate Limiter, Migrations), sat me down at a whiteboard and walked me through how time actually works inside Convex. We get into why Date.now() never changes inside a mutation, why _creationTime doesn't always follow the order things were committed in, and the new commitTs and snapshot timestamp that sort it out. I knew time was a bit special but I didn't realise exactly why it was a problem, so this one kinda blew my mind. Grab yourself a lovely cup of tea and let's dive in. Quick heads up: since we filmed this Ian has tightened things up, so inside a query or mutation snapshotTs ≤ Date.now() ≤ _creationTime is now guaranteed, even with clock skew. There's a note on screen about it at 32:35 too. Commit timestamps in the docs: https://docs.convex.dev/database/advanced/commit-timestamp Why Date.now() is frozen in queries and mutations: https://docs.convex.dev/functions/runtimes Convex 1.43, which added commitTs: https://ship.convex.dev/changelog/convex-v1-43-0 Convex 1.47, which made ctx.meta.getSnapshotTs() public: https://ship.convex.dev/changelog/convex-v1-47-0 Jamie's tweet: https://x.com/jamwt/status/2090873321357197658 My last whiteboard session with Ian, on the Workpool: https://www.youtube.com/watch?v=DQZCQ-Y1ZBM Have you ever had a queue or a cursor skip rows because of timestamps? Let me know down in the comments. Chapters 0:00 A couple of lies about time 1:13 Is time a lie in Convex? 3:36 Three times at play 8:16 Out of order commits 11:25 Why use commit time? 14:49 Is it a number or a new type? 19:43 Is this unique to Convex? 20:26 Do you need to care about this? 25:51 Why isn't creation time commit time? 28:41 Date.now or commit time? 30:37 What's coming up next? Thanks to Ian, and to Emma Forman Ling and Jamie Turner for popping in.