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: getFeatures() invocation in plugin start() unhandled error #1778

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

panaaj
Copy link
Member

@panaaj panaaj commented Aug 21, 2024

(Addresses #1777)
Add test to getFeatures() to check if pluginManager has been initalised prior to interrogating features.

Invoking getFeatures() in a plugin start() function causes an error as the pluginManager is still initialising plugins.

Added a test prior to features being interrogated and throw a meaningful error on exception.

@panaaj panaaj added the fix label Aug 21, 2024
@panaaj panaaj requested a review from tkurki August 21, 2024 04:39
@tkurki
Copy link
Member

tkurki commented Aug 21, 2024

I think the proper fix would be to change getFeatures return type to a Promise. Not really fond of the caller receiving an ambiguous failure, forcing a retry strategy.

This however may create a kind of a deadlock: getFeatures never returns because all plugins do not finish starting up because they are waiting for getFeatures...

Return emtpy plugins array after maxTries has been reached.
@panaaj
Copy link
Member Author

panaaj commented Aug 23, 2024

Implemented a "wait a max number of retries" approach.
Will not throw but rather return an empty array for plugins in return value if maxRetries is reached.

@panaaj
Copy link
Member Author

panaaj commented Sep 4, 2024

@tkurki any further feedback?

@tkurki
Copy link
Member

tkurki commented Sep 8, 2024

I think I was a bit too hasty with my Promise suggestion. I think using PropertyValues would be a much more sane API, as the listeners (other plugins) would be forced to handle updates in the set of features available not only during startup but all the time. For example when another plugin is activated.

What do you think?

Copy link
Member

@tkurki tkurki left a comment

Choose a reason for hiding this comment

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

See my comment about PropertyValues.

@panaaj
Copy link
Member Author

panaaj commented Sep 9, 2024

Seems a reasonable approach to me.
So if I understand correctly:

  1. We don't need to expose getFeatures() to plugins at all....it will only need to service the API endpoint.
  2. Plugins will advertise the features they provide using PropertyValues
  3. API's implemented on the server will also advertise using PropertyValues process.

@tkurki
Copy link
Member

tkurki commented Sep 20, 2024

That's correct. So next steps would be

  • deprecate the current getFeatures: log an error message, remove from the documentation
  • document the PropertyValues mechanism
  • alter APIs in the server to use PropertyValues
  • close this PR...

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

Successfully merging this pull request may close these issues.

2 participants