mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Disable SuperModel retrying
Seems to be causing issues when requests retry with different parameters, for example: https://github.com/codecombat/codecombat/blob/master/app/views/NewHomeView.coffee#L42-L45 This retries without the original GET parameters and returns a 403 as a result.
This commit is contained in:
parent
37d0b23103
commit
d679700966
1 changed files with 29 additions and 25 deletions
|
@ -298,33 +298,37 @@ class ModelResource extends Resource
|
|||
@loadsAttempted = 0
|
||||
|
||||
load: ->
|
||||
# TODO: Track progress on requests and don't retry if progress was made recently.
|
||||
# Probably use _.debounce and attach event listeners to xhr objects.
|
||||
|
||||
# This logic is for handling failed responses for level loading.
|
||||
timeToWait = 5000
|
||||
tryLoad = =>
|
||||
return if this.isLoaded
|
||||
if @loadsAttempted > 4
|
||||
@markFailed()
|
||||
return @
|
||||
@markLoading()
|
||||
@model.loading = false # So fetchModel can run again
|
||||
if @loadsAttempted > 0
|
||||
console.log "Didn't load model in #{timeToWait}ms (attempt ##{@loadsAttempted}), trying again: ", _.result(@model, 'url')
|
||||
@fetchModel()
|
||||
@listenTo @model, 'error', (levelComponent, request) ->
|
||||
if request.status not in [408, 504, 522, 524]
|
||||
clearTimeout(@timeoutID)
|
||||
clearTimeout(@timeoutID) if @timeoutID
|
||||
@timeoutID = setTimeout(tryLoad, timeToWait)
|
||||
if application.testing
|
||||
application.timeoutsToClear?.push(@timeoutID)
|
||||
@loadsAttempted += 1
|
||||
timeToWait *= 1.5
|
||||
tryLoad()
|
||||
@markLoading()
|
||||
@fetchModel()
|
||||
@
|
||||
|
||||
# # TODO: Track progress on requests and don't retry if progress was made recently.
|
||||
# # Probably use _.debounce and attach event listeners to xhr objects.
|
||||
#
|
||||
# # This logic is for handling failed responses for level loading.
|
||||
# timeToWait = 5000
|
||||
# tryLoad = =>
|
||||
# return if this.isLoaded
|
||||
# if @loadsAttempted > 4
|
||||
# @markFailed()
|
||||
# return @
|
||||
# @markLoading()
|
||||
# @model.loading = false # So fetchModel can run again
|
||||
# if @loadsAttempted > 0
|
||||
# console.log "Didn't load model in #{timeToWait}ms (attempt ##{@loadsAttempted}), trying again: ", _.result(@model, 'url')
|
||||
# @fetchModel()
|
||||
# @listenTo @model, 'error', (levelComponent, request) ->
|
||||
# if request.status not in [408, 504, 522, 524]
|
||||
# clearTimeout(@timeoutID)
|
||||
# clearTimeout(@timeoutID) if @timeoutID
|
||||
# @timeoutID = setTimeout(tryLoad, timeToWait)
|
||||
# if application.testing
|
||||
# application.timeoutsToClear?.push(@timeoutID)
|
||||
# @loadsAttempted += 1
|
||||
# timeToWait *= 1.5
|
||||
# tryLoad()
|
||||
# @
|
||||
|
||||
fetchModel: ->
|
||||
@jqxhr = @model.fetch(@fetchOptions) unless @model.loading
|
||||
@listen()
|
||||
|
|
Loading…
Reference in a new issue