Skip to content

Cannot subscribe async on 'backend' event #4

@vedadeepta

Description

@vedadeepta

branch: react-router-v4-fix

Issue.
It throws error :
uncaught: { ReplyError: ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context

Code :

  shareDbServer(
    {
      getHead: getHead,
      appRoutes: {
        main: getMainRoutes()
      },
      beforeStart: beforeStart
    },
    (ee, options) => {
      ee.on('backend', async (backend) => {
        let model = backend.createModel()
        let $files = model.query('files', {})
        console.log(model.subscribeAsync)
        await model.subscribeAsync($files)
        model.destroy()
      })
    }
  )

It throws an error in line await model.subscribeAsync($files)

Quick Fix:
put the code in setTimeout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions