onDisconnect = () => {
        if (runtime.lastError?.message?.indexOf('Could not establish connection') !== -1) {
          this.isConnected = false
          portToBackground.onMessage.removeListener(onPacket)
          portToBackground.onMessage.removeListener(onDisconnect)
          reject('Could not connect to the background script.')
          return
        }

        this.isConnected = false

        for (const id in this.messageMap) {
          const item = this.messageMap[ id ]
          item.reject('Connection was closed')
        }

        this.portMap = {}
        this.portList = []
        this.messageMap = {}
        this.chunkMap = {}

        this.log('Closed connection with the background script.')
      }
We rely on the fact that upon connection is established
the background script will send a @quasar:ports event