lightninglabs / lightninglabs/lnc-web
clear() does not disconnect the active WASM connection, but nothing in the API signals that disconnect() must also be called
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 55
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
`LightningNodeConnect.clear(options?: ClearOptions)` only clears credential state — it
calls `_authCoordinator.clearSession()` and, if `options.persisted === true`,
`_strategyManager.clearAll()`. It never calls into `_wasmManager` in any branch, so the
live WASM connection (and the underlying `wasmClientIsConnected`/`wasmClientInvokeRPC`
state) stays fully alive after `clear()` returns.
Tearing down the connection requires the separate `disconnect()` method
(`WasmManager.disconnect()` removes the `unload` listener and calls
`wasmClientDisconnect()`), and the README's "Clearing Credentials" section already
acknowledges the gap in practice by recommending a full `window.location.reload()` after
`clear()` to guarantee a clean state, rather than documenting `clear()` + `disconnect()`
as the two calls a full logout requires.
The problem is discoverability, not just documentation. An integrator building a logout
flow has no signal from the method name, the `ClearOptions` type, or TypeScript itself
that `clear()` is credential-only — "clear" reads as the complete logout action. Skipping
`disconnect()` leaves the app in a state where credentials are gone but the WASM client is
still connected and could still be invoked via any RPC method that doesn't check auth
state client-side, until eventually cleaned up by an `unload` event the app may not even
trigger (e.g. an SPA route change with no full page reload).
Proposing one of:
1. Have `clear()` also call the equivalent of `disconnect()` by default (with an opt-out
for callers who genuinely want credentials cleared but the socket kept alive), or
2. Add an explicit `disconnect: boolean` field to `ClearOptions` so a full logout is one
call (`clear({ persisted: true, disconnect: true })`) instead of two separately-named,
easy-to-forget methods.
Happy to send a PR for either direction once the preferred approach is confirmed — opening
this first since it changes default behavior of a widely-used public method, which felt
worth discussing before code.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with LightningNodeConnect.clear, ClearOptions, WasmManager.disconnect, and the README's "Clearing Credentials" section; trace how _authCoordinator, _strategyManager, and _wasmManager are used. Confirm the preferred logout contract with maintainers, then update the public API and documentation so the chosen behavior is explicit and the connection state is handled consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, wasm
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100