File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
javascript_client/src/subscriptions Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,22 @@ function createAblyHandler(options: AblyHandlerOptions) {
135135 const disposedChannel = channel
136136 disposedChannel . unsubscribe ( )
137137
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+
138154 await new Promise ( ( resolve , reject ) => {
139155 disposedChannel . detach ( ( err : Types . ErrorInfo ) => {
140156 if ( err ) {
You can’t perform that action at this time.
0 commit comments