We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 03f111f commit 1ea8059Copy full SHA for 1ea8059
1 file changed
javascript_client/src/subscriptions/createAblyHandler.ts
@@ -135,6 +135,22 @@ function createAblyHandler(options: AblyHandlerOptions) {
135
const disposedChannel = channel
136
disposedChannel.unsubscribe()
137
138
+ // Ensure channel is no longer attaching, as otherwise detach does
139
+ // nothing
140
+ if (disposedChannel.state === "attaching") {
141
+ await new Promise((resolve, _reject) => {
142
+ const onStateChange = (
143
+ stateChange: Types.ChannelStateChange
144
+ ) => {
145
+ if (stateChange.current !== "attaching") {
146
+ disposedChannel.off(onStateChange)
147
+ resolve()
148
+ }
149
150
+ disposedChannel.on(onStateChange)
151
+ })
152
153
+
154
await new Promise((resolve, reject) => {
155
disposedChannel.detach((err: Types.ErrorInfo) => {
156
if (err) {
0 commit comments