Skip to content

Conversation

@habdelra
Copy link
Contributor

@habdelra habdelra commented Jan 16, 2026

This PR updates how our prerenderer works so that all chrome tabs are used for rendering, such that a single server can concurrently handle multiple render requests.

Also, it started to drive me nuts, so i added additional logic to spit out lots of detail when we get a fetch failed error in our host tests, enough so that we should be able to feed the logs thru codex to actually fix these flaky tests that result in fetch failed now.

  • Update AWS infra to scale down the number of prerender servers by 75%
  • Add PRERENDER_REALM_TAB_MAX env var to parameter store and infra (let's start with 4 to keep our current SLA)

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 234084aa5b

ℹ️ 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".

@habdelra habdelra marked this pull request as draft January 16, 2026 21:56
@github-actions
Copy link

github-actions bot commented Jan 16, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   1h 36m 47s ⏱️ - 1m 18s
1 887 tests ±0  1 870 ✅ ±0  17 💤 ±0  0 ❌ ±0 
1 902 runs  ±0  1 885 ✅ ±0  17 💤 ±0  0 ❌ ±0 

Results for commit ae08dc6. ± Comparison against base commit 01aaae4.

♻️ This comment has been updated with latest results.

@habdelra habdelra requested a review from Copilot January 16, 2026 22:24
@habdelra habdelra marked this pull request as ready for review January 16, 2026 22:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the prerenderer to enable concurrent rendering across multiple Chrome tabs per server, replacing the previous per-realm serialization model. The changes introduce tab-level queuing and a configurable per-realm tab maximum to optimize resource utilization.

Changes:

  • Removed global per-realm serialization, moving concurrency control to tab-level queuing within PagePool
  • Introduced PRERENDER_REALM_TAB_MAX environment variable to limit concurrent tabs per realm
  • Updated RenderRunner to use a lease/release pattern with try-finally blocks for proper resource cleanup

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/realm-server/tests/prerendering-test.ts Added TestSemaphore and comprehensive tests for concurrent tab usage, queuing behavior, and tab reassignment logic
packages/realm-server/prerender/render-runner.ts Refactored to acquire page leases with release callbacks and ensure cleanup via try-finally blocks; simplified auth change detection
packages/realm-server/prerender/prerenderer.ts Removed per-realm promise chaining and global semaphore acquisition; simplified retry logic by delegating concurrency control to PagePool
packages/realm-server/prerender/page-pool.ts Implemented TabQueue for tab-level queuing, added tab selection logic favoring idle aligned tabs, and introduced transitioning/closing flags to prevent race conditions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 234084aa5b

ℹ️ 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".

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 13 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

Preview deployments

@habdelra habdelra requested a review from a team January 19, 2026 22:31
@habdelra habdelra merged commit fb9f69a into main Jan 20, 2026
161 of 162 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants