Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Don't block other extensions from loading if one activation fails #4805
Don't block other extensions from loading if one activation fails #4805
Changes from 5 commits
4f89f08
95cef8b
199e96a
66b8a91
5452405
16e8e6c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we have already started all the activations above, why not just use a for loop and
try...catch
, then we don't need another field, or the filter, or the map. Just an array topush
to.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the original code, and it seems we want to return even extensions that fail to be activated from
loadExtensions
. I removed the filter and the field to simplify it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should really be mixing
await
and.catch
here since we can easily avoid doing so.I would suggest something like the following:
Furthermore I think the use of
Promise.all
here is a case of using the wrong tool, since we don't actually care about the result. Only the errors (if there are any)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So looking at the code around this, we could easily make
activate
callenable
, have the logging withinLensExtension
and then pass those promises directly to thereturn extensions.map(...)
bellow, because we don't actually need this awaits here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Promise.all
is valid use here, because we want to wait until all the Promises have been resolved.Your try / catch / await is okay.. but has a bit different semantics. It would wait until each extension has been activated, and only print the error in order (e.g. loading extensions A, B and C, if C fails, it would log error from C only after A and B are done). With Promise.all each error from activation will be logged immediately, which is slightly beneficial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do the following:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work for this reason:
Your code example might call .enable before another extension is activated fully, thus causing error.
See earlier PR for some discussion:
#4702
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that parameter becomes
IComputedValue<CatalogEntity | undefined>
and you do anawait when(() => Boolean(entity.get());
before that if, then the race condition would be fixed as well and it would also be fixed for non-bundled extensions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose we fix that in another PR as that's becoming not related to the issue at hand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sounds good