Skip to content

Commit

Permalink
Merge pull request HubSpot#70 from t0mas/master
Browse files Browse the repository at this point in the history
Add timeout attribute to XHR check
  • Loading branch information
zackbloom committed Apr 22, 2014
2 parents 6de5bb1 + 705b135 commit 3204bee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions coffee/offline.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ defaultOptions =
url: ->
# This can be any endpoint, even one that will 404.
"/favicon.ico?_=#{ Math.floor(Math.random() * 1000000000) }"
timeout: 5000

image:
url: ->
Expand Down Expand Up @@ -146,6 +147,9 @@ Offline.checks.xhr = ->
# It doesn't matter what this hits, even a 404 is considered up. It is important however that
# it's on the same domain and port, so CORS issues don't come into play.
xhr.open('HEAD', Offline.getOption('checks.xhr.url'), true)

if xhr.timeout?
xhr.timeout = Offline.getOption('checks.xhr.timeout')

checkXHR xhr, Offline.markUp, Offline.markDown

Expand Down
6 changes: 5 additions & 1 deletion js/offline.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion offline.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3204bee

Please sign in to comment.