diff --git a/assets/javascripts/app/app.coffee b/assets/javascripts/app/app.coffee
index 6bb71224..2ccd0b87 100644
--- a/assets/javascripts/app/app.coffee
+++ b/assets/javascripts/app/app.coffee
@@ -132,6 +132,10 @@
@hideLoading()
return
+ onQuotaExceeded: ->
+ new app.views.Notif 'QuotaExceeded', autoHide: null
+ Raven.captureMessage 'QuotaExceededError'
+
onWindowError: (args...) ->
if @isInjectionError args...
@onInjectionError()
diff --git a/assets/javascripts/app/db.coffee b/assets/javascripts/app/db.coffee
index 6aa8f461..e6c0c7f1 100644
--- a/assets/javascripts/app/db.coffee
+++ b/assets/javascripts/app/db.coffee
@@ -8,7 +8,7 @@ class app.DB
db: (fn) ->
return fn() unless @useIndexedDB
- @callbacks.push(fn)
+ @callbacks.push(fn) if fn
return if @open
try
@@ -39,8 +39,15 @@ class app.DB
onOpenError: (event) =>
event?.preventDefault()
- @useIndexedDB = @open = false
- @runCallbacks()
+ @open = false
+
+ if event?.target?.error?.name is 'QuotaExceededError'
+ @reset()
+ @db()
+ app.onQuotaExceeded()
+ else
+ @useIndexedDB = false
+ @runCallbacks()
return
runCallbacks: (db) ->
diff --git a/assets/javascripts/templates/notif_tmpl.coffee b/assets/javascripts/templates/notif_tmpl.coffee
index 7de9f521..d2ce3836 100644
--- a/assets/javascripts/templates/notif_tmpl.coffee
+++ b/assets/javascripts/templates/notif_tmpl.coffee
@@ -15,6 +15,10 @@ app.templates.notifError = ->
resetting the app.
You can also report this issue on GitHub. """
+app.templates.notifQuotaExceeded = ->
+ textNotif """ Oops, the offline database has exceeded its size limitation. """,
+ """ Unfortunately this quota can't be detected programmatically, and the database can't be opened while over the quota, so it had to be reset. """
+
app.templates.notifInvalidLocation = ->
textNotif """ DevDocs must be loaded from #{app.config.production_host} """,
""" Otherwise things are likely to break. """