Repository navigation
Description
Follow-up to #382 (which addressed the inline-retry blowout) — but the underlying `applyObjectLock` per-invocation cost is still too high on the SCCN-deployed worker.
What happens
`nemar admin publish approve nm000130` (702 S3 objects) and even nm000131-class datasets (24 objects) hit "Too many subrequests by single Worker invocation" inside the s3_lock step. The CLI retry loop reinvokes correctly, but every fresh invocation blows the same cap because each `applyObjectLock` call performs a full `ListObjectsV2` of the dataset prefix before locking 40 objects.
Per-invocation subrequest count
For nm000130 / nm000131-class (small) datasets:
- Auth middleware: 2 D1 (token SELECT + last_used_at UPDATE)
- Get publication request, mark approving, get dataset: 3 D1
- startStep + updateProgress: 2 D1
- listObjectKeys full pagination: ⌈N/1000⌉ S3 LIST calls
- Per-batch PUT retention: 40 calls
For 700 objects, a single invocation = ~7 D1 + 1 LIST + 40 PUTs = 48 subrequests — at or over the cap.
Why this regressed at 0.8.0
Pre-0.8.0 deployment was on the `neuromechanist` Cloudflare account; 0.8.0+ deploys to SCCN (Phase 10 migration, #354). Either the SCCN plan has a tighter subrequest budget or wrangler 4's accounting differs from wrangler 3 (#1153e53 bumped wrangler 3 → 4 in the same release window). Either way the code is too loose for whatever cap we're hitting.
Fix
Switch `s3_lock` from offset-based pagination (full LIST every call) to continuation-token-based streaming:
- Add `applyObjectLockBatch(options, datasetId, continuationToken?, batchSize=15)` that issues exactly 1 `ListObjectsV2` page (`max-keys=batchSize`) + ≤batchSize PUTs.
- Return `{ locked, failed, hasMore, nextContinuationToken }`. Idempotent on re-invocation (already-locked = 403 = success).
- Backend route swaps `s3_lock_offset` for `s3_lock_continuation_token` in the body and response.
- CLI `approvePublication` threads the token through its existing retry loop.
Per-invocation budget after fix: ~7 D1 + 1 LIST + 15 PUTs = ~23 subrequests. Comfortable headroom on any plan, and scales to any dataset size since the LIST cost per invocation is now constant.
Repro
```
$ nemar admin publish approve nm000130 -y
...
[!] s3 lock failed: Too many subrequests by single Worker invocation.
Retrying in 10s (attempt 2/5)...
[!] s3 lock failed: Too many subrequests by single Worker invocation.
Retrying in 10s (attempt 3/5)...
...
```
Activity
fix(s3-lock): stream via continuation token, drop full-list per call
docs: correct the map against branch state, and two errors in ADR 0069
Add the live map for the in-browser compute epic (#1459)