Uncaught Error: UNSOLICITED_MESSAGE: search?...
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)
thanks for raising, what version is this?
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.