Files
orca/cloud/apps/billing/src
Neil c90ba953af fix(cloud): WORKER-XREQ-PROMISE sweep: JWKS, the policy chain, the keyring, and a guard
Follow-up to #801: the rest of the Workers' shared in-flight promises.

- Auth (sandbox-control desktop, staging and dev keys; billing) and the egress proxy's OIDC keys used
  jose's createRemoteJWKSet, which shares one in-flight JWKS fetch across every caller: a request
  cancelled mid-fetch hung every token check behind it, and jose refetches after ten minutes. That
  fits the 'Start sandbox' creates stuck before any log 10–15 min after a deploy and cleared by a
  redeploy. settledRemoteJWKSet keeps the key set as a value; a request that needs a fresh one
  fetches it for itself (refetch every 10 min, an unknown kid at most every 30 s).
- applySandboxPolicy no longer chains writes per sandbox in the isolate (a chained promise from a
  cancelled request would hang every later write for that sandbox); the D1 generation orders them.
- The KMS keyring cache keeps the loaded keyring and the last failure as values; no in-flight load
  is stored at all.
- Guard (both Workers): a unit test fails on createRemoteJWKSet, or a module-level Map, variable
  or object holding a Promise, unless the line says why it is safe ('xreq-ok:', e.g. a WebCrypto
  import).
2026-11-15 14:24:44 -08:00
..