     if navigator.serviceWorker
       # only use service workers if current page has one
       @ready = navigator.serviceWorker.getRegistrations()
+      .catch -> []
       .then (registrations) =>
         if registrations.length
           @sw = new RPCClient({

  listen: =>
    @isListening = true
    selfWindow.addEventListener 'message', @onMessage
    @validation = @client.call 'ping', null, {timeout: @handshakeTimeout}

  close: =>
    @isListening = true

    else
      @ready = Promise.resolve true

    # All parents must respond to 'ping' with @registeredMethods
    @registeredMethods = {
      ping: => Object.keys @registeredMethods
    }
    @parentsRegisteredMethods = []

  setParent: (parent) =>
    @parent = parent
