lightninglabs / lightninglabs/lnc-web

Make disconnect async

Open
#110 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
55
Forks
20
PR merge metrics
No merged PRs in 30d

Description

`wasmClientDisconnect` takes a function that's called when the disconnect has concluded, but `lnc-web` doesn't use it.

As a result, consumers end up needing to do something like this:

```js
lnc.disconnect()
logger.info('disconnecting after:', `payment_hash=${hash}`)
// wait for lnc to disconnect before releasing the mutex
await new Promise((resolve, reject) => {
let counter = 0
const interval = setInterval(() => {
if (lnc.isConnected) {
if (counter++ > 100) {
logger.error('failed to disconnect from lnc')
clearInterval(interval)
reject(new Error('failed to disconnect from lnc'))
}
return
}
clearInterval(interval)
resolve()
})
}, 50)
```

Happy to create a PR myself to the effect of

```js
async disconnect() {
return await new Promise(resolve => this.wasm.wasmClientDisconnect(resolve);
}
```

... if it makes sense

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the lnc-web disconnect() entry point and its wasmClientDisconnect callback. Make disconnect await completion and expose that completion to consumers, then verify callers can await it instead of polling lnc.isConnected.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, wasm
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.