Upgrade Harper to v5 - #5
Conversation
- Add harper@5.0.28 as devDep; add @harperfast/integration-testing@0.4.0 - Rename package to full-page-caching; update description - Add test:integration, start, and dev scripts - Add integrationTests/page-cache.test.ts covering: startup, origin fetch, HTML content-type, cache hit idempotency, and ETag/304 conditional request with async-commit polling (v5 caching contract) - Apply harperBinPath fix (harper exports map workaround) - Add tsconfig.json for integration test type-checking - Add .github/workflows/integration-tests.yml (Node 22/24/26 matrix) - Regenerate package-lock.json with --os=linux --cpu=x64 --include=optional so bufferutil/utf-8-validate/node-gyp-build are recorded for CI - Branding: HarperDB → Harper throughout README; update install command to `npm i -g harper` and dev command to `harper dev .` Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the repository to use the new Harper branding, adds integration tests for the page caching component, and configures TypeScript and package scripts. Feedback on the changes suggests refactoring the fetchUntilCached test helper to avoid returning a disturbed response object, polling before asserting cache hits to account for asynchronous cache commits, and upgrading the TypeScript dependency in package.json to at least ^5.5.0 to support the erasableSyntaxOnly compiler option.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Review finding:
const response = await fetch(new URL(path, origin));
const blob = await createBlob((await response.body));
return { path, pageContents: blob };If the origin returns a 404, 500, or any other error status, the error-page HTML is stored as This bug is not changed by this PR (it pre-exists on if (!response.ok) {
throw new Error(`Origin returned ${response.status} for path: ${path}`);
}And consider adding a test case that verifies a non-200 origin response is NOT cached (i.e., a follow-up request still fetches fresh from origin rather than serving a cached error page). |
- resources.js: throw on non-ok origin responses to prevent caching error pages as 200s - page-cache.test.ts: guard fetchUntilCached timeout to skip instead of misleading assertion failure - page-cache.test.ts: use fetchUntilCached before body equality check to avoid racy cache-miss comparison - page-cache.test.ts: add 504 to status allowlist in all three guard locations Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Review follow-up (autonomous agent): Fixed all 4 blocking findings: origin error responses no longer cached as 200s (resources.js), fetchUntilCached timeout now skips cleanly instead of triggering a misleading assertion, body equality check is no longer racy (uses fetchUntilCached to wait for cache commit), and 504 added to status allowlist at all three guard sites in the integration tests. |
…rowing Throwing causes Harper to return 500; returning null lets the caller receive the upstream status code cleanly without caching the error response. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Bump the harper dependency to ^5.2.1 and regenerate the lockfile. Regenerated in full so the optional native deps (bufferutil, utf-8-validate, segfault-handler) stay in the tree for Linux CI. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The previous lockfile was generated with npm 11, which does not auto-install the peer dependencies of an optional dependency. harper 5.2.1 pulls alasql, which optionally depends on react-native-fs, whose peers (react-native, react) npm 12 installs and npm 11 does not. CI runs npm 12 on Node 24/26, so npm ci failed there with those packages "missing from lock file" while Node 22 (npm 11) passed. Regenerated with npm 12 so the lockfile carries the full tree. lockfileVersion stays 3; npm ci verified under both npm 11 and npm 12. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… TS floor
- fetchUntilCached returns { status, etag, lastModified } instead of the
Response. Every response it fetches is drained, so handing the Response back
gave callers a disturbed body that throws on any later read.
- The second-GET test now also asserts a cache validator is present, so it
cannot be satisfied by two cache MISSes against a static origin.
- typescript: ^5.0.0 -> ^5.8.0. tsconfig sets erasableSyntaxOnly, which needs
5.8; the old range allowed resolving a TS that rejects the option. Lockfile
range updated in place (resolved 5.9.3 already satisfies it) rather than
regenerated, since regenerating with npm 11 locally would drop the optional
peer subtree that npm 12 in CI requires. npm ci --dry-run verified in sync.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Summary
harper@^5.0.28and@harperfast/integration-testing@^0.4.0as devDependencies; removed stalejs-yaml-only lockfile. The app code uses Harper as a runtime-provided global (noharperdbimport in source) so no import swap was needed.resources.jsis already v5-compatible — the sourceget(path)does not usethis.request, there is noblob.save()call, nowasLoadedFromSource(), and nodelete()on the cache table. Code reviewed against all v5 migration checklist items; none required.integrationTests/page-cache.test.tsadded covering: Harper startup, origin HTML fetch,text/htmlcontent-type assertion, cache-hit idempotency (same body on second read), and ETag/304 conditional-request test with async-commit polling (per v5 caching contract — validators appear on HITs, not the priming MISS).harperBinPathfix: applied in test setup to work aroundERR_PACKAGE_PATH_NOT_EXPORTEDfrom harper's restricted exports map..github/workflows/integration-tests.ymladded with Node 22/24/26 matrix and actions pinned to commit hashes.--os=linux --cpu=x64 --include=optional; confirmedbufferutil,utf-8-validate, andnode-gyp-buildare recorded.HarperDB→Harperthroughout README; install command updated tonpm i -g harper; dev command updated toharper dev .; GitHub repo link updated toHarperFast/application-template.start,dev, andtest:integrationtopackage.json.Migration items — N/A
from 'harperdb'import swapTable.get()return shape /wasLoadedFromSource()blob.save()removalcreateBlob()without.save()delete()→invalidate()on cache tabledelete()is not called anywhereTest results
LOCAL: blocked by loopback
EADDRNOTAVAIL(macOS — environmental, not a code bug). CI is the gate.Known issues / flags
full-page-caching(no npm scope). If this should be published under the Harper npm scope, that change requires manual decision — flagged for the team per master plan §11.1.https://www.harperdb.io/— requires outbound network access from CI (standard onubuntu-latest).🤖 Generated with Claude Code