sanity-io / visual-editing

https://visual-editing-studio.sanity.build
MIT License
37 stars 20 forks source link

fix(comlink): ensure nodes always accept handshake synchronize events #2163

Closed rdunk closed 1 week ago

rdunk commented 1 week ago

Currently, comlink's node state machine will only handle syn handshake events when in an idle state. In some situations, the controller or some of the channels it maintains may detect a loss of connection and transition to a handshaking state, the disconnect event emitted at this point may then fail to reach the relevant node(s), and thus the node will remain in a connected state, as the nodes themselves only blindly respond to heartbeat events.

This PR adds a change so that the node state machine will always transition to its internal handshaking state when receiving a syn handshake event, regardless of the state it is currently in. This should greatly improve the success rate of attempt reconnects. For example you may have noticed in our test environments that the connection is often lost after a HMR, this should no longer be the case.

It also drops the default expected response timeout to 3s from 10s for requests for all requests that expect a response except for those initiated with .fetch (which remains at 10s).

vercel[bot] commented 1 week ago

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 Nov 14, 2024 5:45pm
visual-editing-astro βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm
visual-editing-next βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm
visual-editing-next-with-i18n βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm
visual-editing-nuxt βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm
visual-editing-page-builder-demo βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm
visual-editing-remix βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm
visual-editing-storybook βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm
visual-editing-studio βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm
visual-editing-svelte βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 14, 2024 5:45pm