Skip to content

Commit 59952de

Browse files
authored
Merge pull request #46 from lightninglabs/fix-run-again
lnc: fix error when calling connect after run (again)
2 parents 86deb5c + 05c71cf commit 59952de

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

demos/kitchen-sink/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function App() {
1212
const isConnected = () => console.log(lnc.isConnected);
1313
const isReady = () => console.log(lnc.isReady);
1414
const load = () => lnc.preload();
15+
const run = () => lnc.run();
1516
const connect = () => lnc.connect();
1617
const disconnect = () => lnc.disconnect();
1718

@@ -85,6 +86,7 @@ function App() {
8586
<button onClick={() => isReady()}>isReady</button>
8687
<button onClick={() => isConnected()}>isConnected</button>
8788
<button onClick={() => load()}>Load</button>
89+
<button onClick={() => run()}>Run</button>
8890
<button onClick={() => connect()}>Connect</button>
8991
<button onClick={() => disconnect()}>Disconnect</button>
9092
<h1>LND</h1>

lib/lnc.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ export default class LNC {
138138
// do not attempt to connect multiple times
139139
if (this.isConnected) return;
140140

141-
await this.run();
142-
143141
// ensure the WASM binary is loaded
144-
if (!this.isReady) await this.waitTilReady();
142+
if (!this.isReady) {
143+
await this.run();
144+
await this.waitTilReady();
145+
}
145146

146147
const { pairingPhrase, localKey, remoteKey, serverHost } =
147148
this.credentials;

0 commit comments

Comments
 (0)