Skip to content

perf(webapp): cache deployment logs across navigations - #4775

Merged
myftija merged 2 commits into
mainfrom
feat/deployment-logs-cache
Aug 25, 2026
Merged

perf(webapp): cache deployment logs across navigations#4775
myftija merged 2 commits into
mainfrom
feat/deployment-logs-cache

Conversation

@myftija

@myftija myftija commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Switching between deployments in the dashboard re-fetched the whole build log stream from record zero and re-rendered the list line by line every time. Logs are now cached per deployment for the lifetime of the tab: revisiting a deployment shows its logs immediately, and the stream is resumed from the next unread record rather than restarted. Finished deployments whose stream has been read through the finalized event are served entirely from the cache.

Changes

The stream/cache logic moved out of the route into a useDeploymentLogs hook. On each deployment switch it seeds state from the cache, resumes the S2 read session at nextSeqNum, and writes back on cleanup or natural session end. Completion is derived from the stream's own finalized event (plus a terminal deployment status), not from the session closing, so a session cut short by token expiry or a proxy cannot pin a truncated log in the cache.

Memory is bounded by a small LRU (deploymentLogsCache): at most 20 deployments and 20,000 log lines in total, least recently viewed evicted first. The most recently viewed deployment is always kept, so a single very large log can temporarily exceed the line budget on its own. Records are batched into one state update per tick instead of one per line.

Switching between deployments in the dashboard re-read the whole build log
stream from the start every time. Logs are now kept in a small in-memory,
per-tab cache keyed by deployment, seeded instantly on revisit, and the
stream is resumed from the next unread record instead of record zero. A
deployment whose stream has emitted its finalized event and reached a
terminal status is served from the cache without opening a stream at all.

The cache is bounded to 20 deployments and 20k log lines total, evicting
least recently viewed deployments first. Incoming records are also
batched into one state update per tick instead of one per line.
@changeset-bot

changeset-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c29e7bb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@trigger-dot-bot

trigger-dot-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

Preview Deployment

Status Preview Commit Updated
⚪ Removed c29e7bb Aug 25, 13:59 UTC

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds a bounded DeploymentLogsCache with deployment and total-line limits. Adds useDeploymentLogs for cached, resumable S2 log streaming, event parsing, buffering, cleanup, and error handling. Refactors the deployment route to use the hook and the shared DeploymentLogEntry type. Adds tests for cache retrieval, accounting, replacement, recency, and eviction behavior.

Merge Risk: 🔵 Low · up to c29e7

The cache change can leave in-progress logs stale after an idle session ends, delay reuse of finalized logs by up to 60 seconds, and allow some legacy log levels to distort warning or error counts. These are bounded freshness and display-correctness issues, so the PR is mergeable with explicit owner follow-up rather than blocked.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, implementation, cache limits, resumption behavior, and batching. It does not follow the repository template because it omits the issue reference, checklist, testi… Add the required template sections. Include the issue reference, completed checklist items, specific testing steps and results, a short changelog entry, and screenshots or an explicit statement that screenshots are not applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: caching deployment logs across dashboard navigations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, implementation, cache limits, resumption behavior, and batching. It does not follow the repository template because it omits the issue reference, checklist, testing steps, changelog section, and screenshots section.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/deployment-logs-cache

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

…timeouts

An in-progress deployment that produced no log output for 60 seconds ended
the read session and stopped streaming until the next status change. The
session is now reopened from the next unread record until the deployment
is finalized.
@github-actions

Copy link
Copy Markdown
Contributor

Observability map

As of c29e7bb.

19/100 over 449 measured of 467 entry points (base 19, no change)

What this PR changed

route base head now failing
/admin/api/v1/vercel-external-ids/backfill new 0 request-context

FIX FIRST

  • /api/v1/projects/:projectRef/envvars (sensitive) - auth-boundary, request-context
  • /auth/sso (sensitive) - auth-boundary, request-context
  • /_app/orgs/:organizationSlug/settings/team (sensitive) - error-classification, auth-scope, request-context

AUDIT 3 of 50 sensitive mutations record an actor. 47 without one.
CONTEXT 23 of 449 entry points name a tenant on a failure path. 347 appear only here, 39 of them sensitive, in the JSON rather than the fix list.

What the score is made of
CHECKS
  error-classification  181 applicable, 103 pass,   0 sole, global without it 12
  auth-boundary          62 applicable,  57 pass,   0 sole, global without it 16
  auth-scope             19 applicable,  17 pass,   0 sole, global without it 19
  request-context       449 applicable,  23 pass, 246 sole, global without it 64
  audit-trail            50 applicable,   3 pass,   0 sole, not in the score

The score and findings here are report-only and never gate the merge. Separately, a required test suite keeps this tool's symbol and route lists in sync with the code they name, and can fail a pull request that renames or removes a symbol they reference, or that adds the first route with a segment they anticipate. Each failure names the list to edit. The rules and their reasons: internal-packages/observability-map/README.md.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/webapp/app/hooks/useDeploymentLogs.ts (1)

97-139: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add crumb markers to the streaming path.

Add // @Crumbs markers or a `// `#region` `@crumbs block around session creation, resume sequence updates, finalization, and error exits. Keep the markers on the branch until agentcrumbs strip runs before merge.

As per coding guidelines: “Add crumbs as you write code — not just when debugging.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bbe77c1b-cb40-4cad-915d-161e72adb3c7

📥 Commits

Reviewing files that changed from the base of the PR and between 424339d and c29e7bb.

📒 Files selected for processing (1)
  • apps/webapp/app/hooks/useDeploymentLogs.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📜 Review details
⏰ Context from checks skipped due to timeout. (33)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (22, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (23, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (24, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 24)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: obsmap / 🧪 Unit Tests: Observability Map
  • GitHub Check: typecheck / typecheck
  • GitHub Check: fk-cascade-guard / fk-cascade-guard
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: code-quality / code-quality
  • GitHub Check: report
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (9)
Never use `request.signal` to detect client disconnects. Use `getRequestAbortSignal()` from `app/services/httpAsyncStorage.server.ts`, which is wired to Express response close events.

📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts
For dashboard changes, visually verify the running Remix app with Chrome DevTools MCP, using snapshots, screenshots, interaction, and console-message checks as appropriate.

📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts
**Prefer static imports over dynamic imports.** Only use dynamic `import()` when:

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts
Add crumbs as you write code — not just when debugging. Mark lines with

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts
Use zod for validation in packages/core and apps/webapp

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts
Access environment variables through the `env` export of `env.server.ts` instead of directly accessing `process.env`

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts
Use function declarations instead of default exports

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts
Use types over interfaces for TypeScript

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts
When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

Files:

  • apps/webapp/app/hooks/useDeploymentLogs.ts

Comment thread apps/webapp/app/hooks/useDeploymentLogs.ts
@myftija
myftija merged commit ee29393 into main Aug 25, 2026
62 checks passed
@myftija
myftija deleted the feat/deployment-logs-cache branch August 25, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants