Skip to content

feat(aio): add prettier network fail page#16139

Closed
wardbell wants to merge 6 commits intoangular:masterfrom
IdeaBlade:aio-network-fail-page
Closed

feat(aio): add prettier network fail page#16139
wardbell wants to merge 6 commits intoangular:masterfrom
IdeaBlade:aio-network-fail-page

Conversation

@wardbell
Copy link
Copy Markdown
Contributor

@wardbell wardbell commented Apr 19, 2017

closes #16112.

When server or network goes down, we serve a canned page. Current ugly page is described in issue #16112.

This PR provides a prettier page along the lines of the better looking 404 page.
It does NOT cache the page so that, once connectivity is restored, it will try again to get that page.

I found a free “network crashed” svg that’s tiny. I’m loading it in index.html for the obvious reason that it needs to exist when you crash. It should go in the service worker pwa-manifest.json too but I don’t know how to do that.

I would have just put it inline but I don’t know how to position and scale an svg. Maybe this is much ado about too little and we should just use a Material Design Icon.

Update (2nd commit)

  • fixed DocumentService test I broke (refactored for clarity)
  • switched from svg to Material Design icon for lighter weight and fewer complications
  • generalized for non-network fetch error causes.

See it work

  1. Open the Mary Poppins preview
  2. Nav to Docs
  3. Pick a guide doc
  4. Open dev tools, network tab
  5. Click "offline"
  6. Nav to a different guide page; should see the new error page
  7. Nav back to prev. page; it should still display perfectly
  8. Go back online
  9. Nav to the formerly-failed guide page; it loads this time.

Todo

@wardbell wardbell self-assigned this Apr 19, 2017
@wardbell wardbell requested a review from sjtrimble April 19, 2017 00:39
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.

revert

@wardbell wardbell force-pushed the aio-network-fail-page branch 4 times, most recently from 5d8879e to 71fa91d Compare April 19, 2017 06:21
@mary-poppins
Copy link
Copy Markdown

The angular.io preview for daa7d40910fcd57ff0c53b28765ff0c289c5b669 is available here.

@mary-poppins
Copy link
Copy Markdown

The angular.io preview for 739d3188567261115810ba7cddf79f7678891751 is available here.

@mary-poppins
Copy link
Copy Markdown

The angular.io preview for 5d8879e696ed706f5c5d33b328b7b5c78bf8bd27 is available here.

@mary-poppins
Copy link
Copy Markdown

The angular.io preview for 71fa91d5610a517c4ddad913e4c473ac94d22c47 is available here.

@wardbell wardbell added the action: review The PR is still awaiting reviews from at least one requested reviewer label Apr 19, 2017
@wardbell wardbell mentioned this pull request Apr 19, 2017
3 tasks
Copy link
Copy Markdown
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Not related to this PR, but I wish we would use consistent names for variables 😛

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.

Only adding to the cache after the document arrives means that multiple hits to this URL will cause multiple requests until one of them responds.
We should add the observable to the cache when the request is made but then remove it from the cache if the doc that is returned should not be cached.

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.

Something like:

this.cache.set(path, this.fetchDocument(path).do(doc => {
  if (doc.nocache) { this.cache.remove(path); }
});

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.

+1

Copy link
Copy Markdown
Contributor Author

@wardbell wardbell Apr 19, 2017

Choose a reason for hiding this comment

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

Good idea .

@petebacondarwin petebacondarwin added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 19, 2017
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.

what does async attribute do here? images are loaded in an asynchronous fashion by default.

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.

+1

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.

comma missing before "but"?

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.

This text is confusing. How about something shorter and more to the point like: We are sorry, but due to a network issue we can't load document "{{doc}}". Please check your connection and try again.

Copy link
Copy Markdown
Contributor Author

@wardbell wardbell Apr 19, 2017

Choose a reason for hiding this comment

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

Because the error isn't always a network issue. It arises from bad JSON, server down (which is not a network connection), and who knows what else.

The rules for commas and conjunctions, especially "but", are all over the place. Some say add it. Some say never! My research and experience say "no comma" in this place but reasonable minds may differ (no comma in that one :)).

Better is to drop the apology.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can drop the icon altogether too. I just added one because the 404 page had one.

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.

What's the purpose of "error_outline" text in here? I've seen you use this kind of text elsewhere and it's this text that is causing the flicker. Please remove.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm using them exactly as prescribed by the Material Design Guidelines, e.g.,

<i class="material-icons">face</i>

In this case, flicker is highly improbably because there is almost no way to get to this page before the font loads. Therefore, I'm keeping it.

But we need a broader strategy for using MD icons. That should be a separate issue.

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.

Interesting, I didn't know that MD fonts were using ligatures. In that case we must ensure that the font is loaded before we render anything that depends on it.

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.

why is this page implemented differently than the file not found page? you could implement in the same way as 404 and then use service worker and/or <link rel="preload" to cache it. (https://css-tricks.com/prefetching-preloading-prebrowsing/)

Copy link
Copy Markdown
Contributor Author

@wardbell wardbell Apr 19, 2017

Choose a reason for hiding this comment

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

Reasons:

  1. This is the ultimate error fallback. It should never fail. This approach is guaranteed to work even when there is no network (assuming that you've loaded the JS of course).

  2. Service worker is not enabled on most devices.

  3. MDN is not clear on browser support for prefetch.

Why worry? If we're going to get it anyway, and we inline templates routinely, what's wrong with doing it here? Seems simple and sure to me.

@IgorMinar
Copy link
Copy Markdown
Contributor

We also need a different design for this page. This is way too scary and bold.

Among other things the fact that the header is not aligned along with the icon makes it look quite bad.

Current screenshot:
screen shot 2017-04-19 at 3 31 48 pm

@sjtrimble
Copy link
Copy Markdown
Contributor

sjtrimble commented Apr 19, 2017

Take a look at aio/src/styles/1-layouts/_not-found.scss and aio/content/file-not-found.md from https://github.com/angular/angular/pull/16089/files if you want to take on styling. It would be good to use the same exact classes and format so those types of pages are consistent. Otherwise, I can handle once the new issue is filed :)

@wardbell
Copy link
Copy Markdown
Contributor Author

wardbell commented Apr 19, 2017

Updates address the critical objections raised by reviewers.

Stef and I will work on the remaining cosmetic issues in a separate PR.

@petebacondarwin Please note that the entry in the cache for a document that 404s now has the url of the page that was sought rather than the url of the 404 page that we present. Revised tests reflect this coincidental change.

@wardbell wardbell force-pushed the aio-network-fail-page branch from 71fa91d to acbd486 Compare April 19, 2017 21:43
@wardbell wardbell added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 19, 2017
@petebacondarwin
Copy link
Copy Markdown
Contributor

@petebacondarwin Please note that the entry in the cache for a document that 404s now has the url of the page that was sought rather than the url of the 404 page that we present. Revised tests reflect this coincidental change.

No! 😱 That was the whole point of my change previously! We need to be able to assign the pageId in the AppComponent based on the document being rendered not on the current URL. The test was there on purpose and not incidentally incorrect. I think that calling it URL was a red herring that has confused matters.

@petebacondarwin petebacondarwin added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 20, 2017
@mary-poppins
Copy link
Copy Markdown

The angular.io preview for 23b57aa35faf217d449b11b3deb5bca02160c59c is available here.

@petebacondarwin petebacondarwin dismissed their stale review April 20, 2017 15:20

I made changes to this so my review is no longer valid :-)

@mary-poppins
Copy link
Copy Markdown

The angular.io preview for 1925d49 is available here.

@mary-poppins
Copy link
Copy Markdown

The angular.io preview for 9f14ce5 is available here.

@IgorMinar IgorMinar added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 20, 2017
Copy link
Copy Markdown
Contributor Author

@wardbell wardbell left a comment

Choose a reason for hiding this comment

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

Looks great, Pete. Ship it!

mhevery pushed a commit that referenced this pull request Apr 21, 2017
This enables things like embedded components easy access to a clean version
of the current location path.
mhevery pushed a commit that referenced this pull request Apr 21, 2017
)

Dgeni is now providing the `id` for all the documents to be viewed. So we
no longer need to add this to the DocumentContents object.

There are some notable changes in the refactoring:

`DocumentService`:

* The id of the document to render is now obtained from `LocationService.path()`.
* The `getFileNotFoundDoc` and `getErrorDoc` methods have been extracted from
the `fetchDocument` method.

`AppComponent`:

* the `pageId` is now computed in a separate `setPageId` method.

`AppComponen` spec file:

* The `TestHttp` has had the hard coded documents removed and replaced with
a function that will generate docs as needed.
@mhevery
Copy link
Copy Markdown
Contributor

mhevery commented Apr 21, 2017

closed with 9730351

@mhevery mhevery closed this Apr 21, 2017
@wardbell wardbell deleted the aio-network-fail-page branch April 21, 2017 18:33
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
This enables things like embedded components easy access to a clean version
of the current location path.
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
…ular#16139)

Dgeni is now providing the `id` for all the documents to be viewed. So we
no longer need to add this to the DocumentContents object.

There are some notable changes in the refactoring:

`DocumentService`:

* The id of the document to render is now obtained from `LocationService.path()`.
* The `getFileNotFoundDoc` and `getErrorDoc` methods have been extracted from
the `fetchDocument` method.

`AppComponent`:

* the `pageId` is now computed in a separate `setPageId` method.

`AppComponen` spec file:

* The `TestHttp` has had the hard coded documents removed and replaced with
a function that will generate docs as needed.
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
This enables things like embedded components easy access to a clean version
of the current location path.
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
…ular#16139)

Dgeni is now providing the `id` for all the documents to be viewed. So we
no longer need to add this to the DocumentContents object.

There are some notable changes in the refactoring:

`DocumentService`:

* The id of the document to render is now obtained from `LocationService.path()`.
* The `getFileNotFoundDoc` and `getErrorDoc` methods have been extracted from
the `fetchDocument` method.

`AppComponent`:

* the `pageId` is now computed in a separate `setPageId` method.

`AppComponen` spec file:

* The `TestHttp` has had the hard coded documents removed and replaced with
a function that will generate docs as needed.
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: no

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Network connection error looks bad

9 participants