Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
fix: proxy/smoldot providers release connection
Browse files Browse the repository at this point in the history
  • Loading branch information
kratico committed Nov 22, 2022
1 parent fd8e2fc commit cc936fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions rpc/provider/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ export const proxyProvider: Provider<string, Event, Event, Event> = (url, listen
})()
},
release: () => {
let conn
try {
conn = connection(url, listener)
} catch (_error) {
const conn = connections.get(url)
if (!conn) {
return Promise.resolve(undefined)
}
const { cleanUp, listeners, inner } = conn
Expand Down
14 changes: 6 additions & 8 deletions rpc/provider/smoldot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ export const smoldotProvider: Provider<
}
})()
},
release: async () => {
let conn
try {
conn = await connection(props, listener)
} catch (_error) {
return
release: () => {
const conn = connections.get(props)
if (!conn) {
return Promise.resolve(undefined)
}
const { cleanUp, listeners, inner } = conn
listeners.delete(listener)
Expand All @@ -81,10 +79,10 @@ export const smoldotProvider: Provider<
// TODO: utilize `deferClosing` prop once we flesh out approach
inner.remove()
} catch (e) {
return new ProviderCloseError(e as SmoldotCloseErrorData)
return Promise.resolve(new ProviderCloseError(e as SmoldotCloseErrorData))
}
}
return
return Promise.resolve(undefined)
},
}
}
Expand Down

0 comments on commit cc936fc

Please sign in to comment.