Skip to content

Fix post-deployment blank screen with proper cache headers and auto-r…#6205

Merged
alexwillingham merged 6 commits intodevelopfrom
alex/otr-1878-have-to-do-hard-reload-after-deploying-ottehr
Feb 16, 2026
Merged

Fix post-deployment blank screen with proper cache headers and auto-r…#6205
alexwillingham merged 6 commits intodevelopfrom
alex/otr-1878-have-to-do-hard-reload-after-deploying-ottehr

Conversation

@alexwillingham
Copy link
Copy Markdown
Contributor

…eload

Set proper cache headers during S3 deployment to prevent stale bundle 404s:

  • index.html: no-cache (always fresh)
  • Hashed assets: max-age=31536000 (cached for 1 year, immutable)

Add comprehensive chunk loading error detection and auto-reload for both EHR and Intake apps to handle edge cases where users still have cached old index.html files.

alexwillingham and others added 2 commits February 12, 2026 15:42
…eload

Set proper cache headers during S3 deployment to prevent stale bundle 404s:
- index.html: no-cache (always fresh)
- Hashed assets: max-age=31536000 (cached for 1 year, immutable)

Add comprehensive chunk loading error detection and auto-reload for both EHR and Intake apps to handle edge cases where users still have cached old index.html files.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The generic "Failed to fetch" pattern could incorrectly trigger auto-reload
on normal API call failures. Now only checking for specific chunk loading
error patterns that won't interfere with runtime API calls.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
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 addresses post-deployment “blank screen” incidents by reducing the chance of clients requesting deleted/stale JS chunks (via improved S3 cache-control headers) and by adding client-side detection of chunk load failures that triggers an automatic reload.

Changes:

  • Add global chunk-load failure detection (window error + unhandledrejection) with auto-reload in both Intake and EHR entrypoints.
  • Expand EHR’s existing ErrorBoundary handling to detect more chunk-loading failure signatures.
  • Update Intake and EHR CI S3 deploy scripts to upload index.html with no-cache and sync other files with long-lived cache headers.

Reviewed changes

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

File Description
apps/intake/src/index.tsx Adds global handlers to detect chunk loading failures and reload the page.
apps/intake/package.json Changes deploy scripts to set explicit cache-control headers for S3 uploads.
apps/ehr/src/index.tsx Adds global handlers + expands ErrorBoundary reload logic for chunk loading failures.
apps/ehr/package.json Changes deploy scripts to set explicit cache-control headers for S3 uploads.

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

Comment thread apps/intake/package.json Outdated
Comment thread apps/intake/src/index.tsx Outdated
Comment thread apps/ehr/package.json Outdated
Comment thread apps/ehr/src/index.tsx Outdated
Comment thread apps/ehr/src/index.tsx Outdated
alexwillingham and others added 4 commits February 12, 2026 16:04
Window event listeners already catch all chunk loading errors globally.
Keeping ErrorBoundary for general React error logging only.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
JavaScript error handlers can't catch main bundle 404s because the code
never loads in the first place. The actual fix is ensuring index.html is
never cached via proper Cache-Control headers on S3 deployment.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add ordered_cache_behavior blocks to both EHR and Patient Portal CloudFront distributions to disable caching for index.html using AWS's CachingDisabled policy. This ensures users always get the latest index.html after deployments, preventing blank screens from stale cached HTML with outdated bundle references.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@alexwillingham
Copy link
Copy Markdown
Contributor Author

This requires some deploys to test, so let's be sure to check how it goes as we deploy it through various envs!

@alexwillingham alexwillingham merged commit 8927f77 into develop Feb 16, 2026
14 checks passed
@alexwillingham alexwillingham deleted the alex/otr-1878-have-to-do-hard-reload-after-deploying-ottehr branch February 16, 2026 13:58
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.

4 participants