Web engineer building fast websites & apps for founders. I test AI coding tools in real workflows and share honest breakdowns: architecture, costs, what's hype. Guides at nilesharma.space
Running linking as recursive SQL is a fun idea, and discovering the import graph one level at a time explains the four to eight times remote slowdown better than blaming the network would. One thing I kept thinking about is the build lock. AWS's docs say an If-None-Match write fails whenever "an identical key name is found in the bucket", so the lock only clears when something deletes that object. If the builder times out or gets killed mid-build, what stops later visitors from seeing "another visitor started this build" forever? Does the lock object carry a timestamp or owner so a stale one can be taken over?
Edoardo Dusi is a Senior Developer Advocate at AWS, part of the EMEA Developer Relations team. He spent years building web platforms and leading teams before moving into DevRel.
Good catch, and you read the docs right: the create-only write never clears itself. Two things cover it. The lock body is just a timestamp, and when a visitor finds an existing lock older than two minutes it treats it as a dead build and takes it over with a second conditional write, IfMatch on the ETag it just read, so if two visitors spot the same stale lock only one of them wins.
Then a lifecycle rule on locks/ expires anything older than a day, as a backstop. No owner id in the object, the ETag does that job. It's in acquireLock() in distributed/serve/server.js if you want to look at it. Two minutes is generous for this demo, a real system would size it from the slowest build plus some slack, or heartbeat the lock while building.
Web engineer building fast websites & apps for founders. I test AI coding tools in real workflows and share honest breakdowns: architecture, costs, what's hype. Guides at nilesharma.space
The IfMatch takeover on the ETag is a neat trick. It makes stealing a stale lock safe without storing an owner id, and the lifecycle rule covers the case where nobody comes back. Heartbeating the lock sounds like the natural next step for longer builds. Thanks for pointing me to acquireLock().
Software engineer who builds things that run in production — and writes deep-dive guides on why they break. I explain how React, Node, Docker, Rust and Kubernetes actually work under the hood.
Hey Edoardo! 25 of 56 checks passing, query returning same number whatever you asked... I've been handed that 'done' lol. recursive SQL for ResolveExport, I'd steal that xD :)
Edoardo Dusi is a Senior Developer Advocate at AWS, part of the EMEA Developer Relations team. He spent years building web platforms and leading teams before moving into DevRel.
Ha, thank you! Yeah the function was fast because it never read the question :D That's why I now ask the agent for tests it didn't write for itself before I read any walkthrough! Steal away, the linker is in src/sql.js in the repo and the same query runs in the plain sqlite3 shell
Software engineer who builds things that run in production — and writes deep-dive guides on why they break. I explain how React, Node, Docker, Rust and Kubernetes actually work under the hood.
Thanks Edoardo!! tests it didn't write for itself, ok that one's going on my wall lol. tuesday night mine... wrote a test, passed, I was hovering over merge and then wait, the expected value was just the bug wearing a hat?? nearly shipped it, tea was already cold. src/sql.js tonight then, if sqlite3 shell runs it I can actually poke at it :D
Edoardo Dusi is a Senior Developer Advocate at AWS, part of the EMEA Developer Relations team. He spent years building web platforms and leading teams before moving into DevRel.
Software engineer who builds things that run in production — and writes deep-dive guides on why they break. I explain how React, Node, Docker, Rust and Kubernetes actually work under the hood.
mine's still that tuesday one... 1am, tea gone cold, me reading the expected value out loud like 'hold on. hold on hold on' because it was literally just the bug again?? green tick and all. haven't trusted a first green since, not really. anyway thanks Edoardo, needed that laugh tonight :D
Edoardo Dusi is a Senior Developer Advocate at AWS, part of the EMEA Developer Relations team. He spent years building web platforms and leading teams before moving into DevRel.
Running linking as recursive SQL is a fun idea, and discovering the import graph one level at a time explains the four to eight times remote slowdown better than blaming the network would. One thing I kept thinking about is the build lock. AWS's docs say an If-None-Match write fails whenever "an identical key name is found in the bucket", so the lock only clears when something deletes that object. If the builder times out or gets killed mid-build, what stops later visitors from seeing "another visitor started this build" forever? Does the lock object carry a timestamp or owner so a stale one can be taken over?
Good catch, and you read the docs right: the create-only write never clears itself. Two things cover it. The lock body is just a timestamp, and when a visitor finds an existing lock older than two minutes it treats it as a dead build and takes it over with a second conditional write,
IfMatchon the ETag it just read, so if two visitors spot the same stale lock only one of them wins.Then a lifecycle rule on
locks/expires anything older than a day, as a backstop. No owner id in the object, the ETag does that job. It's inacquireLock()indistributed/serve/server.jsif you want to look at it. Two minutes is generous for this demo, a real system would size it from the slowest build plus some slack, or heartbeat the lock while building.The IfMatch takeover on the ETag is a neat trick. It makes stealing a stale lock safe without storing an owner id, and the lifecycle rule covers the case where nobody comes back. Heartbeating the lock sounds like the natural next step for longer builds. Thanks for pointing me to acquireLock().
Hey Edoardo! 25 of 56 checks passing, query returning same number whatever you asked... I've been handed that 'done' lol. recursive SQL for ResolveExport, I'd steal that xD :)
Ha, thank you! Yeah the function was fast because it never read the question :D That's why I now ask the agent for tests it didn't write for itself before I read any walkthrough! Steal away, the linker is in
src/sql.jsin the repo and the same query runs in the plainsqlite3shellThanks Edoardo!! tests it didn't write for itself, ok that one's going on my wall lol. tuesday night mine... wrote a test, passed, I was hovering over merge and then wait, the expected value was just the bug wearing a hat?? nearly shipped it, tea was already cold. src/sql.js tonight then, if sqlite3 shell runs it I can actually poke at it :D
"The bug wearing a hat" is going on my wall now :D
deal lol, wall trade accepted
mine's still that tuesday one... 1am, tea gone cold, me reading the expected value out loud like 'hold on. hold on hold on' because it was literally just the bug again?? green tick and all. haven't trusted a first green since, not really. anyway thanks Edoardo, needed that laugh tonight :D
Never trust an agent 😄 Glad I've helped!!!
the database storing a copy of itself inside itself is my favourite row in that claims table lol. an accidental quine