diff --git a/package-lock.json b/package-lock.json index 1a052bde..162c98ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sanity/client", - "version": "6.18.0", + "version": "6.18.1-canary.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@sanity/client", - "version": "6.18.0", + "version": "6.18.1-canary.0", "license": "MIT", "dependencies": { "@sanity/eventsource": "^5.0.2", diff --git a/package.json b/package.json index 2820fe8e..82ab73c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sanity/client", - "version": "6.18.0", + "version": "6.18.1-canary.0", "description": "Client for retrieving, creating and patching data from Sanity.io", "keywords": [ "sanity", diff --git a/src/data/listen.ts b/src/data/listen.ts index f49aed19..52ffe86d 100644 --- a/src/data/listen.ts +++ b/src/data/listen.ts @@ -171,6 +171,10 @@ export function _listen = Record>( .then((eventSource) => { if (eventSource) { es = eventSource + // Handle race condition where the observer is unsubscribed before the EventSource is set up + if (unsubscribed) { + unsubscribe() + } } }) .catch((reason) => {