This slow (approx. 3 minutes) single Ajax request through Ember.JS generates 2 server requests each 10ms long in the server logs, one at the beginning and one at the end. But Google Chrome Developer Tools and Firefox's Firebug only show 1 Ajax request.
It can be only reproduced in production server running a unicorn Rails app through nginx. That means locally one Ajax request produces only 1 server request log entry. I'm using Rails 4.2.1, Ember JS 1.13.8, Ember Data 1.13.8 and jQuery 1.9.1.
The use case is 1 delete a user ranking item and then reload the current route through a hack about going first to a "no data" route and then back to the current route.
These are my Ember JS controller actions:
destroy: (id) ->
$.ajax("/api/v1/user_ranking_items/#{id}", type: 'DELETE').done((data) =>
@send('getRanking')
).fail((data) ->
alert 'Removing item failed!'
)
getRanking: ->
@transitionToRoute 'no_data'
@transitionToRoute('profile.rankings', @get('adjective'), @get('negativeAdjective'), @get('topic'), @get('scope'), @get('page'))
and this is my route profile.rankings which generates 2 server requests one at the beginning and one at the end:
Volontariat.ProfileRankingsRoute = Ember.Route.extend
model: (params) ->
@store.query(
'user_ranking_item',
user_id: Volontariat.User.current().id, adjective: params.adjective,
negative_adjective: params.negative_adjective, topic: params.topic,
scope: params.scope, page: params.page
)
In the meantime I'm migrating to Ember 2.0 and hope this solves the issue.
Aucun commentaire:
Enregistrer un commentaire