You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Was fighting a bug for a few hours that was caused by groq-store swallowing an error caused by passing an invalid query to groq-js's parse() function. This invalid query is likely a bug in groq-js because the query works in every other sanity-io tool.
When groq-store is consumed by another library, the error thrown by groq-js is not logged in the console, so it was very difficult to trace it to this.
Therefore, I think the store.subscribe() function should check to see if the query is valid, because otherwise the subscription would appear as though it is broken / not receiving any updates.
The text was updated successfully, but these errors were encountered:
store.subscribe(`*[wat`,{},(err,result)=>{if(err){console.error('Oh no, an error:',err)return}console.log('Result:',result)})
This logs:
Oh no, an error: GroqSyntaxError: Syntax error in GROQ query at position 5
at Object.parse$1 [as parse] (/Users/holm/Documents/Sanity/groq-store/node_modules/groq-js/dist/groq-js.cjs.development.js:5427:38)
at query (/Users/holm/Documents/Sanity/groq-store/dist/node/groq-store.js:314:25)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
position: 5
}
Oh no, an error: GroqSyntaxError: Syntax error in GROQ query at position 5
at Object.parse$1 [as parse] (/Users/holm/Documents/Sanity/groq-store/node_modules/groq-js/dist/groq-js.cjs.development.js:5427:38)
at query (/Users/holm/Documents/Sanity/groq-store/dist/node/groq-store.js:314:25)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
position: 5
}
It's a bit weird that it logs it twice, but other than that it's getting sent correctly.
My mistake, I incorrectly assumed the error was not being sent back up, but it was. I wasn't checking the error object when using the hook in next-sanity
Referencing sanity-io/groq-js#29
Was fighting a bug for a few hours that was caused by groq-store swallowing an error caused by passing an invalid query to
groq-js
'sparse()
function. This invalid query is likely a bug in groq-js because the query works in every other sanity-io tool.When groq-store is consumed by another library, the error thrown by
groq-js
is not logged in the console, so it was very difficult to trace it to this.Therefore, I think the
store.subscribe()
function should check to see if the query is valid, because otherwise the subscription would appear as though it is broken / not receiving any updates.The text was updated successfully, but these errors were encountered: