Title: pkarr-worker(retention): RETENTION_SECONDS is parsed with a bare Number() and no guard — '0'/'7d'/' ' schedule the deletion alarm at/before now (or NaN), so stored packets vanish right after a 204, and '1e9' never expires · Issue #3261 · developing-today/code · GitHub
Open Graph Title: pkarr-worker(retention): RETENTION_SECONDS is parsed with a bare Number() and no guard — '0'/'7d'/' ' schedule the deletion alarm at/before now (or NaN), so stored packets vanish right after a 204, and '1e9' never expires · Issue #3261 · developing-today/code
X Title: pkarr-worker(retention): RETENTION_SECONDS is parsed with a bare Number() and no guard — '0'/'7d'/' ' schedule the deletion alarm at/before now (or NaN), so stored packets vanish right after a 204, and '1e9' never expires · Issue #3261 · developing-today/code
Description: Summary pkgs/pkarr-worker: RETENTION_SECONDS is parsed with a bare Number(...) and no validity guard in PkarrStore.putPacket (src/index.ts:67-68), and the resulting timestamp is handed straight to setAlarm, whose handler unconditionally ...
Open Graph Description: Summary pkgs/pkarr-worker: RETENTION_SECONDS is parsed with a bare Number(...) and no validity guard in PkarrStore.putPacket (src/index.ts:67-68), and the resulting timestamp is handed straight to ...
X Description: Summary pkgs/pkarr-worker: RETENTION_SECONDS is parsed with a bare Number(...) and no validity guard in PkarrStore.putPacket (src/index.ts:67-68), and the resulting timestamp is handed straight to ...
Opengraph URL: https://github.com/developing-today/code/issues/3261
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pkarr-worker(retention): RETENTION_SECONDS is parsed with a bare Number() and no guard — '0'/'7d'/' ' schedule the deletion alarm at/before now (or NaN), so stored packets vanish right after a 204, and '1e9' never expires","articleBody":"## Summary\n\n`pkgs/pkarr-worker`: `RETENTION_SECONDS` is parsed with a bare `Number(...)` and no validity guard in `PkarrStore.putPacket` (`src/index.ts:67-68`), and the resulting timestamp is handed straight to `setAlarm`, whose handler unconditionally deletes the stored record. Any value that is not a plain positive decimal silently breaks retention for every record in that object:\n\n- `\"0\"`, `\"-1\"`, or a whitespace-only `\" \"` (truthy, so the `|| \"604800\"` fallback does not fire; `Number(\" \")` is 0) → the deletion alarm is scheduled at or before now, so the record a PUT just stored (and returned 204 for) is deleted again almost immediately; later GETs 404.\n- `\"7d\"` or any non-numeric spelling → `retentionMs` is `NaN` and the alarm time is `NaN` — the expiry behaviour is whatever the runtime does with an invalid alarm time, instead of the documented 7 days.\n- `\"1e9\"` → silently reinterpreted as 1,000,000,000 seconds (~31,700 years): records effectively never expire, contradicting the header contract that \"records expire after RETENTION_SECONDS without refresh\".\n\nThe same file already shows the house pattern for exactly this: `DNS_TTL` is parsed in `handleDoh` (`src/index.ts:224-226`) with `Number.isFinite(ttl) && ttl > 0 ? ttl : 30` — a guarded parse with a sane fallback. The retention parse has no equivalent guard.\n\n## Evidence (main `f4f800e7`)\n\n- `src/index.ts:67-68` — `const retentionMs = Number(this.env.RETENTION_SECONDS || \"604800\") * 1000; await this.ctx.storage.setAlarm(Date.now() + retentionMs);` No `isFinite`, no positivity check, no fallback beyond the empty-string `||`.\n- `src/index.ts:86-88` — `alarm()` runs `DELETE FROM record WHERE id = 1` unconditionally, so a past-due alarm removes the current record, including one stored seconds earlier.\n- `src/index.ts:224-226` — the guarded `DNS_TTL` contrast in the same file.\n- `wrangler.jsonc:18` sets `\"RETENTION_SECONDS\": \"604800\"` — the value is operator-edited config (a var, not code), so a units slip (`\"7d\"`, `\"604800 \"` variants, `\"0\"` while testing) reaches the parse unvalidated.\n- Distinct from #3252 (deploy.mjs `--dry-run` on the deploy-version path — deploy tooling, not the Worker's runtime config) and #1828/#1829 (the deployment standard this Worker pilots).\n\n## Verified (laptop probe, exact expressions from `index.ts:67`)\n\nProbe: `~/git/fleet/probe-2026-10-31-laneA-pkarr-retention/` on the laptop — `src/index.ts` sha256 `a751bb4d…` identical in the laptop clone and the sandbox checkout at main `f4f800e7`; the probe evaluates the verbatim `:67` expression:\n\n```\nundefined -> retentionMs = 604800000 | alarm in past / invalid: false\n\"604800\" -> retentionMs = 604800000 | alarm in past / invalid: false\n\"0\" -> retentionMs = 0 | alarm in past / invalid: true\n\"-1\" -> retentionMs = -1000 | alarm in past / invalid: true\n\"7d\" -> retentionMs = NaN | alarmAt = NaN\n\" \" -> retentionMs = 0 | alarm in past / invalid: true\n\"1e9\" -> retentionMs = 1000000000000 | ~31,700-year retention\n\"3600.5\" -> retentionMs = 3600500 | fractional seconds accepted silently\n```\n\n(The Durable Object alarm itself was not executed — no node_modules on the laptop for the workers vitest pool; the claim verified here is the parse layer plus the unconditional-delete alarm handler in the source. A past-due `setAlarm` firing promptly is documented Durable Object behaviour.)\n\n## Why it matters\n\nRetention is the only expiry mechanism for stored pkarr packets: the store has one row per key and `getPacket` performs no age check, so the alarm is the whole contract. A config slip therefore fails in the worst two directions at once — live records vanishing right after a successful publish (clients see 204, then 404), or records never expiring at all — with no error anywhere: `putPacket` returns `\"stored\"` in every case above except a possible runtime throw on the NaN alarm.\n\n## Acceptance criteria\n\n- [ ] `RETENTION_SECONDS` is parsed with the same discipline as `DNS_TTL`: a non-finite, non-positive, or non-plain-decimal value falls back to the 604800s default (or is rejected loudly at startup), never reaching `setAlarm` as 0/negative/NaN.\n- [ ] With `RETENTION_SECONDS` set to `\"0\"`, `\"7d\"`, and `\" \"` (one test each), a PUT still stores the packet and a subsequent GET returns it, with the alarm scheduled ~7 days out.\n- [ ] Scientific/fractional spellings (`\"1e9\"`, `\"3600.5\"`) are either rejected-to-default or explicitly documented as accepted — not silently reinterpreted.\n- [ ] Regression tests in the workers vitest suite cover the bad-value cases alongside the existing `\"604800\"` behaviour, which is unchanged.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-31T23:50:48Z","url":"https://github.com/developing-today/code/issues/3261"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a4543e4a-f7c2-6ced-9808-eda8208f4213 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D9C6:1293AE:98CEB5:C66AD1:6B06341E |
| html-safe-nonce | 3f6c1f1f0389ee16440211871cc5d93b26188fe837f712c91d10a810216591d0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUM2OjEyOTNBRTo5OENFQjU6QzY2QUQxOjZCMDYzNDFFIiwidmlzaXRvcl9pZCI6IjkyMTYyNzk1OTU5NDU3MDI0MzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 80c6bdd1d1a59967e32f59747c21fd174c88f96f6f5347a6bec81255ce56879a |
| hovercard-subject-tag | issue:6141136771 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/developing-today/code/3261/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5999430923883aefd7a9ec017abcfd6500afd1d0a575a0762c5c67fa39b1bd2d/developing-today/code/issues/3261 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5999430923883aefd7a9ec017abcfd6500afd1d0a575a0762c5c67fa39b1bd2d/developing-today/code/issues/3261 |
| og:image:alt | Summary pkgs/pkarr-worker: RETENTION_SECONDS is parsed with a bare Number(...) and no validity guard in PkarrStore.putPacket (src/index.ts:67-68), and the resulting timestamp is handed straight to ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | c3584c853cd39700ecff6e2cf8364295ffdb5313e571046c41cd2479270f7df0 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9eb3bb1597d09170a5f282cd38ae376dee1a5ec1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width