# \[Solved\] Home page loads fine, inner pages do not (can-zone ignore)

**URL:** <https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977>\
**Category:** DoneJS\
**Created:** [October 15, 2018, 7:38am UTC](https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977 "2018-10-15T07:38:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![leoj3n](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/leoj3n/32/174_2.png) [@leoj3n](https://forums.bitovi.com/u/leoj3n)\
**Post date:** [October 15, 2018, 7:38am UTC](https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977/1 "2018-10-15T07:38:56Z")

</div>

Here is a screenshot of `http://localhost:3030/contributors` that shows a persistent error:

 ![32%20AM](https://canada1.discourse-cdn.com/flex035/uploads/donejs/original/1X/88734be75f2319fc253a9771098250aec8567666.png)

There are different errors upon first load of that page (probably before SSR has cached the page or something):

 ![39%20AM](https://canada1.discourse-cdn.com/flex035/uploads/donejs/original/1X/f9c5aadf16229552aace9781c9fee462feb4141f.png)

If you visit the deployed app, the errors are not displayed or shown in console, and the HTML table contains no data (SSR should be able to get the data regardless of client):

[https://bitcentivez.herokuapp.com/contributors](https://bitcentivez.herokuapp.com/contributors)

At one point SSR was getting the data and it was just the client not being able to reattach without timeout.

If you visit [https://bitcentivez.herokuapp.com](https://bitcentivez.herokuapp.com) and then click the “Contributors” menu item, the inner page loads as expected (unless you click off the Home page super fast, before client app is reattached).

I’m guessing there is an issue with SRR not being able to connect to with the data needed for that inner page, if that makes sense.

The code for that inner “Contributors” page is here:

- [https://github.com/leoj3n/bitcentivez/tree/master/client/components/page-contributors](https://github.com/leoj3n/bitcentivez/tree/master/client/components/page-contributors)

I’m guessing I need to use can-zone ignore but I’m not sure how.

---

<div class="post-metadata">

**Author:** ![leoj3n](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/leoj3n/32/174_2.png) [@leoj3n](https://forums.bitovi.com/u/leoj3n)\
**Post date:** [October 15, 2018, 7:49am UTC](https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977/2 "2018-10-15T07:49:03Z")

</div>

The error upon first page load (after fresh server restart) mentions `can-observation-recorder`, so it may be that [https://canjs.com/doc/can-observation-recorder.ignore.html](https://canjs.com/doc/can-observation-recorder.ignore.html) could be useful in some way as well, but again I am not sure and I definitely require guidance using either ignore function (have been trying to debug this for a while now without any success on my own).

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [October 19, 2018, 1:55pm UTC](https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977/4 "2018-10-19T13:55:12Z")

</div>

Sorry, can you create a minimal version that breaks in the same way?

---

<div class="post-metadata">

**Author:** ![leoj3n](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/leoj3n/32/174_2.png) [@leoj3n](https://forums.bitovi.com/u/leoj3n)\
**Post date:** [October 20, 2018, 10:56am UTC](https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977/5 "2018-10-20T10:56:50Z")

</div>

Hi Justin, thanks for replying.

The example repo/project is pretty barebones, and it’s directly adapted from a small subset of the official and original [donejs/bitcentive](https://github.com/donejs/bitcentive) example code, so you should already be pretty familiar with most of it!

I could rip out the styles and assets, but the problem is with the minimal amount of JavaScript… SSR works perfectly fine if you enter the app through the Home page, and then navigate to the Contributors page using the navbar… The problem appears when you try to visit `/contributors` directly.

You can at least please try cloning this down, to do a quick local investigation of the problem?

That should be easy as:

```bash
mongod --config /usr/local/etc/mongod.conf # Or, using brew services: brew services start mongodb

git clone https://github.com/leoj3n/bitcentivez.git && cd bitcentivez && npm install && npm run develop-ssr

open http://localhost:3030/contributors # reload to see the different second error, or restart server to see initial error again

```

The code for the **SSR server** is here:

- [server/app.js](https://github.com/leoj3n/bitcentivez/blob/master/server/app.js#L8) **(requires `./middleware`)**
- [server/middleware/index.js](https://github.com/leoj3n/bitcentivez/blob/master/server/middleware/index.js#L11) **(requires `ssr.js`)**
- [server/middleware/ssr.js](https://github.com/leoj3n/bitcentivez/blob/master/server/middleware/ssr.js) **(requires `done-ssr-middleware`)**

The code for the **contributors service** (the only service) is here:

- [server/services](https://github.com/leoj3n/bitcentivez/tree/master/server/services)

The code for the **contributor model** (the only model) is here:

- [client/models](https://github.com/leoj3n/bitcentivez/tree/master/client/models)

The code for my custom-built **super-model** (a kitchen sink of behaviors) is here:

- [client/lib/super-model.js](https://github.com/leoj3n/bitcentivez/blob/master/client/lib/super-model.js)

The pertinent **client app js and stache templates** are here:

- [client/app.js](https://github.com/leoj3n/bitcentivez/blob/master/client/app.js)
- [client/index.stache](https://github.com/leoj3n/bitcentivez/blob/master/client/index.stache#L27-L31)
- [client/components/page-contributors/page-contributors.js](https://github.com/leoj3n/bitcentivez/blob/master/client/components/page-contributors/page-contributors.js)
- [client/components/page-contributors/page-contributors.stache](https://github.com/leoj3n/bitcentivez/blob/master/client/components/page-contributors/page-contributors.stache#L6-L8)

Let me know what you’re seeing that you would want stripped out before you would be willing take a look.

Thank you!

---

<div class="post-metadata">

**Author:** ![leoj3n](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/leoj3n/32/174_2.png) [@leoj3n](https://forums.bitovi.com/u/leoj3n)\
**Post date:** [October 27, 2018, 12:34pm UTC](https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977/6 "2018-10-27T12:34:59Z")

</div>

Okay, I was able to get this to work. I based my solution off of this one use of `zone` in the original bitcentive:

> <https://github.com/donejs/bitcentive/blob/b6a2ff10c07c7adfa2b023d39bbdf2b979f48b83/public/app.js#L37-L39>

Here’s where I needed to put it and what it ended up looking like in my bitcentivez project:

> <https://github.com/leoj3n/bitcentivez/blob/f76251a1fa602e3844a31def222fc63822590bcf/client/components/page-contributors/page-contributors.js#L7-L9>

I knew from the start that I needed to ignore something in zones for SSR to work, but I just didn’t know what exactly. Removing parts of the application like @justinbmeyer suggested pointed out to me that SSR would work if `return Contributor.getList({});` was removed from the client app. Once I knew this I just needed to figure out how to use `can-zone`'s ignore feature.

Unfortunately, the `can-zone` docs page on the [canjs.com](http://canjs.com) site is 404ing, and the README doesn’t have any usage examples. I don’t know why but I didn’t think to check to see if the `can-zone` repo had a `docs` folder until now, which it does:

> <https://github.com/canjs/can-zone/blob/master/docs/ignore.md>

Instead I ended up finding the example in the original bitcentive. At any rate, it seems I can finally use SSR in my app without being frustrated that it’s broken for pages that load data via feathers.

I guess one assumption I still would like answered is: SSR should be able to load data from feathers without having to use `CanZone.ignore`. I assume this is the case, but is just not fully supported yet, and for now we have to use `CanZone.ignore` as suggested in these issues:

[https://github.com/canjs/can-zone/issues/149](https://github.com/canjs/can-zone/issues/149)

[https://github.com/canjs/can-zone/issues/108](https://github.com/canjs/can-zone/issues/108)

Is that assumption about `can-zone` and SSR compatibility with data from feathers (for example) correct?

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [October 27, 2018, 10:54pm UTC](https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977/7 "2018-10-27T22:54:58Z")

</div>

We aren’t using ssr in our Bitcentive app. Feathers will not work by default because it uses a long lived websocket connection.

There is a way to configure the feathers client to use XHR. You’d have to switch to this when running the app in ssr.

Glad you were able to use bisection to figure out the problem.

---

<div class="post-metadata">

**Author:** ![leoj3n](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/leoj3n/32/174_2.png) [@leoj3n](https://forums.bitovi.com/u/leoj3n)\
**Post date:** [October 30, 2018, 3:12am UTC](https://forums.bitovi.com/t/solved-home-page-loads-fine-inner-pages-do-not-can-zone-ignore/977/8 "2018-10-30T03:12:09Z")

</div>

Thanks Justin, I was able to use `feathers-rest` on the server and `feathers-socketio` on the client with the help of `steal-conditional`:

[https://github.com/leoj3n/bitcentivez/commit/bce502921c9d49b6efab90fb48e4d841217ba516](https://github.com/leoj3n/bitcentivez/commit/bce502921c9d49b6efab90fb48e4d841217ba516)

However, although it works locally in development, I encountered the following issue when attempting to build and deploy:

[https://github.com/stealjs/steal-tools/issues/1086](https://github.com/stealjs/steal-tools/issues/1086)

It seems `steal-conditional` causes the conditionally loaded files to not get included in the bundle. 🤔

You can see the resulting error in the console on that page: [https://bitcentivez.herokuapp.com/contributors](https://bitcentivez.herokuapp.com/contributors)

NOTE (to future self):

Here are some related issues that might benefit from this method of loading `feathers-rest` in SSR:

```auto
https://github.com/donejs/bitcentive/issues/97
https://github.com/donejs/done-ssr/issues/198
https://github.com/canjs/can-connect-feathers/pull/104

```
