Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency between server and client side rendering when params are passed to a collection #350

Closed
por opened this issue Mar 24, 2014 · 5 comments
Labels

Comments

@por
Copy link
Contributor

por commented Mar 24, 2014

Ran into this problem with my own app, and was able to reproduce with the 00_simple example app.

Steps to reproduce:

  1. In app/controllers/users_controller.js: add sort param to repos collection.

    show: function(params, callback) {
      ...
      repos: {collection: 'Repos', params: {
        user: params.login,
        sort: 'pushed'
      }}
      ...
  2. Load a user page by navigating to it (e. g. from Users page), but make sure the user data is not cached on the client.

  3. Refresh the user profile, which causes a server side rendering.

Expected result:

Both pages render exactly the same.

Actual result:

Client behaves as expected, server ignores the sort=pushed param and lists the repositories alphabetically.

I’m not sure all parameters passed to the collection should be sent as query parameters by default, maybe that should be done by the app logic, but we should at least make sure client and server behave the same in this scenario.

@benjie
Copy link
Contributor

benjie commented Mar 24, 2014

I think #198 is relevant to this issue - I think the root of it is the difference between client and server handling of params introduced by 8c8d7ef. I get around this for now by overriding the fetch method for controllers only when isServer to append the params to the URL.

@lo1tuma
Copy link
Member

lo1tuma commented Mar 25, 2014

I can reproduce this, but not with the same steps that you described.
Steps:

  1. the same step as yours
  2. Load a user page by navigating to it (e. g. from Users page), but make sure the user data is not cached on the client.
  3. Refresh the user profile, which causes a server side rendering

@por
Copy link
Contributor Author

por commented Mar 25, 2014

@lo1tuma I can see where my steps were confusing, I updated the description with your step 2 and 3.

@lo1tuma lo1tuma added the bug label Mar 25, 2014
@rickysahu
Copy link

It seems like the sort parameter is not the root cause. I'm also able to reproduce this with the steps @lo1tuma mentioned. @por, you can see that the # of repos is also missing in the client side view. I went pretty far back on the commit history and am able to reproduce this issue even before 8c8d7ef.

Oddly, if we try and reproduce the same issue using Repos instead of Users in example 00_simple, the client/server side render the same content via these steps: 1) cleanly load /repos 2) click on any repo url (e.g. /repos/mojombo/grit) 3) refresh and you see the same content.

@dettier
Copy link

dettier commented Apr 9, 2014

@benjie is right, it is broken since commit 8c8d7ef.
serverSync function, unlike clientSync, doesn't use options.data to create url anymore. Seems like there's no way to make it work now without overriding syncer code.

Considering number of repos missing, it is due to client side caching. It can be fixed by adding ensureKeys : [ 'public_repos' ] in user_controller show action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants