Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

feat(sendHtml): allow custom error page #281

Merged
merged 44 commits into from
Sep 15, 2020

Conversation

JamesSingleton
Copy link
Contributor

@JamesSingleton JamesSingleton commented Aug 19, 2020

Description

This allows ONE_FALLBACK_URL to be given in order to define a custom
error page.

So this will require documentation on it, but I wanted to wait for approvals just in the off chance that the implementation changes due to reviews.

Motivation and Context

Allow someone to override the default error page.

How Has This Been Tested?

This was tested locally returning renderStaticErrorPage(res) and testing with different scenarios. Also, unit tests.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • These changes should be applied to a maintenance branch.
  • This change requires cross browser checks.
  • Performance tests should be ran against the server prior to merging.
  • This change impacts caching for client browsers.
  • This change impacts HTTP headers.
  • This change adds additional environment variable requirements for One App users.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using One App?

They can now provide ONE_FALLBACK_URL to be used as the error page instead of the default.

This allows ONE_FALLBACK_URL to be given in order to define a custom
error page.
@oneamexbot
Copy link
Contributor

oneamexbot commented Aug 19, 2020

📊 Bundle Size Report

file name size on disk gzip
app.js 275.4KB 82.2KB
runtime.js 15KB 5.4KB
vendors.js 117.2KB 36.4KB
app~vendors.js 432.5KB 112.2KB
service-worker-client.js 17KB 5.2KB
legacy/app.js 290.7KB 85.4KB
legacy/runtime.js 15KB 5.4KB
legacy/vendors.js 172.7KB 47.1KB
legacy/app~vendors.js 441.3KB 114.5KB
legacy/service-worker-client.js 17.5KB 5.4KB

Generated by 🚫 dangerJS against 6317bac

@Francois-Esquire
Copy link
Contributor

@JamesSingleton Could we add documentation for ONE_FALLBACK_URL and how we can use this feature?

@JamesSingleton
Copy link
Contributor Author

@JamesSingleton Could we add documentation for ONE_FALLBACK_URL and how we can use this feature?

Yeah, I was going to wait to add the docs until after the reviews in the off chance that implementation changes based on feedback. I mentioned that in the description, I wish we could add "tasks" to be completed.

src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
${message}
</p>
</div>
const fallbackUrl = process.env.ONE_FALLBACK_URL;
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, we will need to have this environment variable validated alongside the other env variables.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add ONE_FALLBACK_URL to runTime.js
mtomcal
mtomcal previously approved these changes Aug 19, 2020
src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
__tests__/server/middleware/sendHtml.spec.js Outdated Show resolved Hide resolved
@@ -69,30 +81,36 @@ export function renderStaticErrorPage(res) {
message = 'Sorry, we are unable to load this page at this time.';
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to have this custom too? especially with internationalization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly in another PR, this PR is just to allow a custom error page.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is meant to be the final catch all. we can not add anything that could risk an error being thrown here.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we provide, a default option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally if they wanted a custom message they would just use a custom error page right?

__tests__/server/middleware/sendHtml.spec.js Outdated Show resolved Hide resolved
src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
@@ -69,30 +81,36 @@ export function renderStaticErrorPage(res) {
message = 'Sorry, we are unable to load this page at this time.';
Copy link
Contributor

Choose a reason for hiding this comment

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

this is meant to be the final catch all. we can not add anything that could risk an error being thrown here.

src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
@JamesSingleton JamesSingleton marked this pull request as draft August 26, 2020 17:59
@JamesSingleton JamesSingleton marked this pull request as ready for review August 27, 2020 19:24
src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
src/server/middleware/sendHtml.js Show resolved Hide resolved
src/server/middleware/sendHtml.js Show resolved Hide resolved
Copy link
Contributor

@JAdshead JAdshead left a comment

Choose a reason for hiding this comment

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

after offline discussion, warn don't throw when failing to update error page.
This is to prevent one-app failing to start when pods scale / restart due to an external factor "e.g network issue fetching error page"

__tests__/server/middleware/sendHtml.spec.js Outdated Show resolved Hide resolved
docs/api/modules/App-Configuration.md Outdated Show resolved Hide resolved
src/server/middleware/sendHtml.js Show resolved Hide resolved
src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
infoxicator
infoxicator previously approved these changes Sep 11, 2020
Copy link
Contributor

@infoxicator infoxicator left a comment

Choose a reason for hiding this comment

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

Apart from a couple of optionals suggestions to the name of the tests this looks really good 👍

__tests__/server/middleware/sendHtml.spec.js Outdated Show resolved Hide resolved
__tests__/integration/one-app.spec.js Outdated Show resolved Hide resolved
__tests__/server/middleware/sendHtml.spec.js Show resolved Hide resolved
infoxicator
infoxicator previously approved these changes Sep 11, 2020
src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
src/server/middleware/sendHtml.js Outdated Show resolved Hide resolved
@JamesSingleton JamesSingleton merged commit 73eb8a7 into master Sep 15, 2020
@JamesSingleton JamesSingleton deleted the feature/custom-error-page branch September 15, 2020 21:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants