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

chore: await initialization before routing a msg #2364

Merged
merged 14 commits into from
May 2, 2023
Merged

chore: await initialization before routing a msg #2364

merged 14 commits into from
May 2, 2023

Conversation

bumi
Copy link
Collaborator

@bumi bumi commented Apr 19, 2023

This uses a deferred promise to make sure the initialization has finished before we process a message call.
This also fixes some LNC issues and makes sure that the WASM is namespaced.

This uses a deferred promise to make sure the initialization has
finished before we process a message call.
@github-actions
Copy link

github-actions bot commented Apr 19, 2023

🚀 Thanks for the pull request!

Here are the current build files for testing:

Download and unzip the file for your browser. Refer to the readme for detailed install instructions.


This build is brought to you by: channel.ninja (who recently dropped 1000 sats):


Want to sponsor the next build? send some sats to ⚡️builds@getalby.com (don't forget to provide your name)

Don't forget: keep earning sats!

utils.openUrl("welcome.html");
}
if (isRecentlyUpdated) {
migrate();
Copy link
Contributor

@rolznz rolznz Apr 20, 2023

Choose a reason for hiding this comment

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

Should we consider moving migrate() to the bottom of the init() function? it is also an asynchronous function which I believe should run before the init finishes?

Copy link
Contributor

Choose a reason for hiding this comment

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

You probably mean to the top of the init function, right? For me it would make sense to await the migration and only then resolveInit to avoid calls being executed while migrations are still taking place.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree resolveInit shouldn't be called until the migrations have run. But don't the migrations depend on init? that's why I suggested it being moved to the last line in the init() function.

@rolznz
Copy link
Contributor

rolznz commented Apr 20, 2023

@bumi the fix works well for me, for a basic test of adding a 10 second sleep to the start of the init function. Without the fix doing this does some strange things, like launching the welcome screen and asking to set a new password.

@reneaaron
Copy link
Contributor

Did some testing and added delays to test. Routing calls are stacked during initialization and resolved after that: 👍️

image

bumi added 3 commits April 29, 2023 22:43
* master:
  fix: change link color to blue-600 / blue-700 on hover (#2372)
  feat: lnurlpay screen toggle more fields (#2373)
  chore: yarn lock
  fix: wait for transactions to load
  fix: use account id from connector directly
  fix: tabs hover / dark mode (#2360)
  feat: add account-context balanceLoading (#2359)
  yarn lock file
  bug: show no txs msg after loading
  bug: show no txs  msg after loading
* origin/await-init:
  fix: only log migration message if recently updated
  chore: re-add isRecentlyUpdated check
  chore: also wait for migrations before finishing init
Immediatlly set the connector to make sure a second getConnector() call
returns the same connector instance.
bumi added 4 commits May 1, 2023 22:05
LNC initializes a wasm instance which also has some callbacks and writes
those in a global variable based on the namespace. Without the namespace
the wasm varable gets reused and the credentials get overwritten.

https://github.com/lightninglabs/lnc-web/blob/
af1604c26295b86191d8f97a71a3f6cab6433812/lib/lnc.ts#L74-L76
Just in case there is any react dependency on it
@bumi bumi marked this pull request as ready for review May 1, 2023 20:16
@bumi bumi requested review from reneaaron and rolznz May 1, 2023 20:16
@socket-security
Copy link

New dependency changes detected. Learn more about Socket for GitHub ↗︎


👍 No new dependency issues detected in pull request

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

Pull request alert summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

📊 Modified Dependency Overview:

⬆️ Updated Package Version Diff Added Capability Access +/- Transitive Count Publisher
@lightninglabs/lnc-web@0.2.4-alpha 0.2.2-alpha...0.2.4-alpha None +1/-1 kaloudis

await msg.request("selectAccount", {
id: accountId,
});
setAccountId(accountId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you change the order here?

This leads to some side effects (e.g. the avatar changes only after the account has been loaded) 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is that a problem?

I wanted to avoid some react dependency to do requests before the new account was switched.

@bumi bumi merged commit ae360c8 into master May 2, 2023
@bumi bumi deleted the await-init branch May 2, 2023 12:26
@reneaaron reneaaron mentioned this pull request May 2, 2023
3 tasks
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

Successfully merging this pull request may close these issues.

3 participants