Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make connect timeout configurable (or something else) #111

Open
huumn opened this issue Apr 27, 2024 · 1 comment
Open

Make connect timeout configurable (or something else) #111

huumn opened this issue Apr 27, 2024 · 1 comment

Comments

@huumn
Copy link

huumn commented Apr 27, 2024

The package currently waits a hardcoded second for the connection to succeed and when that times out it leaves the connection in an undetermined state. Increasing the timeout could give someone more certainty the connection actually failed.

This might be legacy code considering usage of WithBlock in lightning-node-connect's grpc.DialOptions is listed as a deprecated antipattern.

Anyway, it's hard to determine, as a consumer of connect, how to recover when the function reports a failure.

lnc-web/lib/lnc.ts

Lines 226 to 250 in f65cf92

// repeatedly check if the connection was successful
return new Promise<void>((resolve, reject) => {
let counter = 0;
const interval = setInterval(() => {
counter++;
if (this.isConnected) {
clearInterval(interval);
resolve();
log.info('The WASM client is connected to the server');
// clear the in-memory credentials after connecting if the
// credentials are persisted in local storage
if (this.credentials.password) {
this.credentials.clear(true);
}
} else if (counter > 20) {
clearInterval(interval);
reject(
new Error(
'Failed to connect the WASM client to the proxy server'
)
);
}
}, 500);
});

@lnbc1QWFyb24
Copy link

Yes I second this, would love to be able to configure the timeout to be a bit longer. It seems to be 50/50 chance of successful connection at times as it times out just before successfully connecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants