[WRONG BRANCH] fix(server): share stable dashboard asset snapshots - #382
[WRONG BRANCH] fix(server): share stable dashboard asset snapshots#382luvs01 wants to merge 1 commit into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
⏳ DRAFT
What to do
Its title has been prefixed with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 053e403fd4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Blob owns one immutable copy that every response can share. This keeps a response | ||
| // stable across package replacement without allocating the asset again per request. | ||
| const blob = new Blob([readFileSync(path)], { type: contentType }); | ||
| staticAssetSnapshots.set(path, { fingerprint, blob }); |
There was a problem hiding this comment.
Evict snapshots for obsolete asset paths
When a running source checkout rebuilds the dashboard—or a live package update replaces it—Vite gives changed JS/CSS bundles new content-hashed paths. Each subsequently requested bundle is retained by this process-wide map, while entries for the now-deleted paths are never removed and their full Blob contents remain reachable. Repeated dashboard rebuilds or updates therefore accumulate roughly one GUI bundle per version for the lifetime of the proxy, undermining the memory-amplification fix; bound the cache or purge entries that no longer belong to the current gui/dist snapshot.
Useful? React with 👍 / 👎.
Motivation
Description
StaticAssetSnapshotstructure and a process-widestaticAssetSnapshotscache keyed by file path and an inode/mtime fingerprint to detect replacements and reuse snapshots.staticAssetSnapshot(path, contentType)which stat-guards the file, returns a cachedBlobwhen the fingerprint matches, and otherwise creates and caches one immutableBlobfrom the file bytes.readFileSync(filePath)response body with a sharedBlobreturned fromstaticAssetSnapshot, while preservingContent-TypeandbrowserSecurityHeadersand leaving HTML handling unchanged.tests/gui-static.test.tsto assert that an already-created response retains the original bytes while a subsequent request after replacement receives the refreshed asset.Testing
bun test tests/gui-static.test.ts, which passed.bun run typecheck, which passed.git diff --check/ repository checks (no whitespace or check errors).bun run test; the full suite run exposed unrelated pre-existing failures (anapi-catalog-routeauth assertion expecting401returned403, and achat-completionstest timed out) so the long full-suite run was stopped after those unrelated failures.Codex Task