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 extension loader race conditions #1815

Merged
merged 5 commits into from
Dec 23, 2020
Merged

Conversation

jakolehm
Copy link
Contributor

Fixes following issues:

  • discovery emitted "add" events on app boot -> caused multiple extension install runs
  • watch started before bundled extensions were ready
  • user installed extensions were re-installed on boot (now install happens only during add)
  • discovery used single package.json which was mutated on the fly, now it uses package.json only for bundled extensions

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jakolehm jakolehm added bug Something isn't working area/extension Something to related to the extension api labels Dec 20, 2020
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jakolehm jakolehm marked this pull request as ready for review December 20, 2020 12:10
@jakolehm jakolehm requested a review from a team December 20, 2020 12:10
@jakolehm jakolehm added this to the 4.0.5 milestone Dec 20, 2020
const bundledExtensions = await this.loadBundledExtensions();

await this.installPackages(); // install in-tree as a separate step
const localExtensions = await this.loadFromFolder(this.localFolderPath);
await this.installPackages(this.packageJsonPath, bundledExtensions);
Copy link
Contributor

Choose a reason for hiding this comment

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

We install only bundled extensions here, but when do we install user extensions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We install them only when they are added.

extensionDiscovery.init();
windowManager = WindowManager.getInstance<WindowManager>(proxyPort);

// call after windowManager to see splash earlier
try {
const extensions = await extensionDiscovery.load();

// Start watching after bundled extensions are loaded
extensionDiscovery.watchExtensions();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how this is broken, watchExtensions contains await this.whenLoaded; which is set at the end of load

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can probably revert this, I did separate these just to understand the current flow better.

// The path to the manifest file is the lens extension id
// Note that we need to use the symlinked path
const lensExtensionId = path.join(this.nodeModulesPath, extensionName, manifestFilename);
const lensExtensionId = extension.manifestPath;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we actually remove this variable and use extension.id?

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 if they are the same thing.. I just tried to keep this compatible with current logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

They should be the same. In the old implementation the id was created manually because we didn't have the extension object itself.

Copy link

@MinKhent88 MinKhent88 left a comment

Choose a reason for hiding this comment

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

#48320

MinKhent88
MinKhent88 previously approved these changes Dec 21, 2020
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
nevalla
nevalla previously approved these changes Dec 22, 2020

await this.installPackages();
const extensions = bundledExtensions.concat(localExtensions);
const userExtensions = await this.loadFromFolder(this.localFolderPath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be good, in a future PR, to remove the dependence on this folder so that we can no longer use explicit symlinks and instead have a list of "dev" extensions to just require?

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, that would be good improvement (but cannot be done in a patch release).

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay sounds good. Maybe 4.1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

4.1 is already quite loaded but we can try.

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jakolehm jakolehm merged commit 75c70a1 into master Dec 23, 2020
@jakolehm jakolehm deleted the fix/extension-load-race-conds branch December 23, 2020 09:56
jakolehm added a commit that referenced this pull request Dec 23, 2020
* fix extension loader race conditions

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* cleanup

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix remove

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* ensure symlinked (dev) extensions are installed on boot

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jakolehm jakolehm mentioned this pull request Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/extension Something to related to the extension api bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants