Akryum / Akryum/vue-cli-plugin-apollo
restartWebsockets does not properly re-open the WebSocket connection
- 主要言語
- JavaScript
- スター
- 477
- フォーク
- 109
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
The graphql-client function `restartWebsockets` is called during the `onLogin` and `onLogout` functions provided by the `vue-apollo.js` template in order to update the authentication header of the WebSocket connection.
https://github.com/Akryum/vue-cli-plugin-apollo/blob/d9fe48c61cc19db88fef4e4aa5e49b31aa0c44b7/generator/templates/vue-apollo/default/src/vue-apollo.js#L80-L106
`restartWebsockets` force-closes the current WebSocket connection, opens a new one, and attempts to push all existing subscriptions to the new connection.
https://github.com/Akryum/vue-cli-plugin-apollo/blob/d9fe48c61cc19db88fef4e4aa5e49b31aa0c44b7/graphql-client/src/index.js#L194-L212
However, manually sending `GQL_START` messages serves only to restore the WebSocket messages. The message handlers, which were destroyed by `wsClient.close`, are never restored. Because of this, the Vue-Apollo smart queries/subscriptions will no longer receive updates. A manual refresh of the page is required to fully restore the subscriptions.
Details in [`subscriptions-transport-ws`](https://github.com/apollographql/subscriptions-transport-ws):
- [`SubscriptionClient.close`](https://github.com/apollographql/subscriptions-transport-ws/blob/567fca89cb4578371877faee09e1630dcddff544/src/client.ts#L152-L173) calls [`SubscriptionClient.unsubscribeAll`](https://github.com/apollographql/subscriptions-transport-ws/blob/567fca89cb4578371877faee09e1630dcddff544/src/client.ts#L161)
- [`SubscriptionClient.unsubscribeAll`](https://github.com/apollographql/subscriptions-transport-ws/blob/567fca89cb4578371877faee09e1630dcddff544/src/client.ts#L255-L259) calls [`SubscriptionClient.unsubscribe`](https://github.com/apollographql/subscriptions-transport-ws/blob/567fca89cb4578371877faee09e1630dcddff544/src/client.ts#L257) on each operation (subscription)
- [`SubscriptionClient.unsubscribe`](https://github.com/apollographql/subscriptions-transport-ws/blob/567fca89cb4578371877faee09e1630dcddff544/src/client.ts#L661-L667) [deletes the operation](https://github.com/apollographql/subscriptions-transport-ws/blob/567fca89cb4578371877faee09e1630dcddff544/src/client.ts#L663)
- After `restartWebsockets` manually reinstates the WebSocket messages using `GQL_START`, messages begin to arrive
- [`SubscriptionClient.processReceivedData`](https://github.com/apollographql/subscriptions-transport-ws/blob/567fca89cb4578371877faee09e1630dcddff544/src/client.ts#L585-L659) attempts to call the handler for the operation, but the operation does not exist, as it was deleted by the `unsubscribe` call.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。