Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(comlink): handle heartbeat compatibility correctly #2006

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

stipsan
Copy link
Member

@stipsan stipsan commented Oct 21, 2024

After a lot of debugging I noticed that every time @sanity/[email protected] sent a channel/heartbeat like this:

    {
        "connectionId": "46d4c484-df9c-4c7f-b633-d1739330567e",
        "domain": "sanity/channels",
        "from": "presentation",
        "id": "b9cf5be9-e64e-4efb-812b-4ace7c98c857",
        "to": "overlays",
        "type": "channel/heartbeat"
    }

The connection was lost.
Comparing payloads and versions, @sanity/[email protected] responds with:

   {
        "connectionId": "46d4c484-df9c-4c7f-b633-d1739330567e",
        "data": {
            "responseTo": "b9cf5be9-e64e-4efb-812b-4ace7c98c857"
        },
        "domain": "sanity/channels",
        "from": "overlays",
        "id": "b19f2420-e0d2-4156-9d36-982162129df2",
        "to": "presentation",
        "type": "channel/response"
    }

And all is well.
While @sanity/[email protected] responds with:

   {
        "connectionId": "46d4c484-df9c-4c7f-b633-d1739330567e",
        "domain": "sanity/channels",
        "from": "overlays",
        "id": "msg-68f6d443-70e8-4306-abfb-9f2c6ee043e9",
        "to": "presentation",
        "type": "channel/response",
        "responseTo": "b9cf5be9-e64e-4efb-812b-4ace7c98c857"
   }

The only difference I could find where:

   {
        "connectionId": "46d4c484-df9c-4c7f-b633-d1739330567e",
-        "data": {
-            "responseTo": "b9cf5be9-e64e-4efb-812b-4ace7c98c857"
-        },
        "domain": "sanity/channels",
        "from": "overlays",
        "id": "b19f2420-e0d2-4156-9d36-982162129df2",
        "to": "presentation",
        "type": "channel/response",
+       "responseTo": "b9cf5be9-e64e-4efb-812b-4ace7c98c857"
    }

I found the compat layer and tested the fix there, adding back data.responseTo if there were no data already, and also a responseTo present.
@sanity/[email protected] can connect to both @sanity/[email protected] and @sanity/[email protected] without issues 😮‍💨

@stipsan stipsan requested a review from a team as a code owner October 21, 2024 20:13
Copy link

vercel bot commented Oct 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
live-visual-editing-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-astro ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-next-with-i18n ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-nuxt ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-page-builder-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-remix ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm
visual-editing-svelte ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2024 8:13pm

@stipsan stipsan merged commit 65af1e1 into main Oct 21, 2024
20 checks passed
@stipsan stipsan deleted the fix-comlink-compatibility branch October 21, 2024 20:16
@ecospark ecospark bot mentioned this pull request Oct 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant