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

Fix node connection issues #1504

Merged
merged 3 commits into from
Aug 4, 2023
Merged

Conversation

myxmaster
Copy link
Contributor

@myxmaster myxmaster commented Jun 16, 2023

Description

This fixes #1492 and fixes #1479.

#1479 was caused by cached backend calls being used although the node config was changed. So the calls are now removed when reconnecting to a node.

#1492 was due to results of older requests being received and processed after the results of newer requests. Now, results of non-latest requests are generally discarded.

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Configuration change
  • Locales update
  • Quality assurance
  • Other

Checklist

  • I’ve run yarn run tsc and made sure my code compiles correctly
  • I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • I’ve run yarn run prettier and made sure my code is formatted correctly
  • I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • Android
  • iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

  • LND (REST)
  • LND (Lightning Node Connect)
  • Core Lightning (c-lightning-REST)
  • Core Lightning (Spark)
  • Eclair
  • LndHub

Locales

  • I’ve added new locale text that requires translations
  • I’m aware that new translations should be made on the Zeus Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • Contributors will need to run yarn after this PR is merged in
  • 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • Changes were made that require an update to the README
  • Changes were made that require an update to onboarding

Copy link
Contributor

@shubhamkmr04 shubhamkmr04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR resolved the issue 1492, was not able to re-create 1479, looks already resolved in master

@myxmaster
Copy link
Contributor Author

Just checked again with v0.7.7-beta2 and #1479 is still reproducible. Did you follow the steps to reproduce 100% @shubhamkmr04 ?

In my opinion this PR still solves both issues and should be merged.

@@ -1026,6 +1026,7 @@ export default class SettingsStore {
if (status) {
this.error = false;
this.errorMsg = '';
BackendUtils.clearCachedCalls();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably check first if clearCachedCalls is defined as it isn't defined for all backends

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not necessary since the call function of BackendUtils already checks this.

BackendUtils.getMyNodeInfo()
.then((data: any) => {
if (NodeInfoStore.currentRequest !== currentRequest) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain the logic here? I don't see currentRequest getting redefined. Just on line 47

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is only defined on line 47. If the response for a request is processed after a newer request is sent, the currentRequest objects don't match and thus the response is discarded.

@action
public getNodeInfo = () => {
this.errorMsg = '';
this.loading = true;
const currentRequest = (NodeInfoStore.currentRequest = {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this.currentRequest suffice in place of NodeInfoStore.currentRequest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is NodeInfoStore.currentRequest because the property is static. Static properties cannot be accessed using this.. My idea was to make it static to discard responses even if there are multiple instances of NodeInfoStore (which should never be the case).

But I realized that this makes no sense since even if there were multiple instances, they all have their own state and then they should also have their own currentRequest object.

Copy link
Contributor

@kaloudis kaloudis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uTACK

@kaloudis kaloudis merged commit bb7e660 into ZeusLN:master Aug 4, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants