deepstream.io-client-js icon indicating copy to clipboard operation
deepstream.io-client-js copied to clipboard

Uncaught Error: UNSOLICITED_MESSAGE: search?...

Open teckays opened this issue 8 years ago • 2 comments

I've seen a lot of issues regarding the UNSOLICITED_MESSAGE error but couldn't find something related to my use case:

This is the code:

const result = client.record.getList( 'search?' + query )  
return new Promise(resolve => {
  result.whenReady(async r => {
    const ids = r.getEntries()
    let entries = await Promise.all(ids.map(async (id) => client.record.get(id)))
    resolve(entries)
    result.delete()
  })
})

this is the error:

webpack:///./node_modules/deepstream.io-client-js/dist/lib/client.js?:204 Uncaught Error: UNSOLICITED_MESSAGE: search?{"table":"project","query":[["createdBy","eq","teckays"]]} (R)
    at Client._$onError (webpack:///./node_modules/deepstream.io-client-js/dist/lib/client.js?:204)
    at RecordHandler._$handle (webpack:///./node_modules/deepstream.io-client-js/dist/lib/record/record-handler.js?:370)
    at Client._$onMessage (webpack:///./node_modules/deepstream.io-client-js/dist/lib/client.js?:147)
    at Connection._onMessage (webpack:///./node_modules/deepstream.io-client-js/dist/lib/message/connection.js?:366)

teckays avatar Feb 01 '18 19:02 teckays

thanks for raising, what version is this?

yasserf avatar Feb 02 '18 11:02 yasserf

Ah I think I know the issue!

Putting a delete within the whenReady is likely to be the culprit. Delete gets rid of the core and potentially that breaks. Will put a test case in V4 thank you. Generally you would only need to do a discard on the frontend and not a delete but its a valid usecase regardless.

V4 syntax now btw:

async function () {
  const result = client.record.getList( 'search?' + query )
  await result.whenReady()
  const ids = r.getEntries()
  let entries = await Promise.all(ids.map(async (id) => client.record.get(id)))
  entries.discard()
  return entries
}

In a super ideal world if we do a snapshot it would wait till a pattern is matched but that involves way too much work.

yasserf avatar Jun 04 '19 08:06 yasserf