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

download-plugins: raise error in case of errors downloading plugins #8788

Merged

Conversation

perrinjerome
Copy link
Contributor

@perrinjerome perrinjerome commented Nov 27, 2020

What it does

Fixes: #7819.

If something went wrong while downloading plugins, the build should be
interrupted, instead of creating an environment where some plugins might
be missing.

How to test

One possible way is to add invalid entries in theiaPlugins from package.json, for example:

  "theiaPlugins": {
    "error-404": "https://open-vsx.org/404",
    "error-invalid-url": "not url"
  }

and use yarn download:plugins.

Without these changes, the command exits with success status code:

image

There are messages in red, yes, but the build report a success.

With the changes from this pull request, the command exit with error status code:

image

Review checklist

Reminder for reviewers

@perrinjerome perrinjerome force-pushed the fix/download-plugin-error branch from f8f47a3 to e0d68b6 Compare November 27, 2020 11:05
@vince-fugnitto vince-fugnitto added the theia-cli issues related to the theia-cli label Nov 27, 2020
@perrinjerome perrinjerome force-pushed the fix/download-plugin-error branch from e0d68b6 to 8cb5f52 Compare November 30, 2020 00:44
@paul-marechal
Copy link
Member

Technically this is a breaking change since this script is public and people might have relied on it always exiting with code 0.

Can you add a flag like --fail which will make it throw when set? Feel free to use a better name if you have one.

Also add an entry to the CHANGELOG to mention this new flag. Thanks :)

@perrinjerome
Copy link
Contributor Author

Thank you, that's right, this would be a breaking change. I pushed more commits to introduce a --tolerate-download-failures flag and a CHANGELOG entry:

  • [download:plugins] errors when downloading plugins now result in build failures, unless --tolerate-download-failures flag is passed. #8788

PS: I'm not sure I correctly understood the suggestion properly about what should be the default behaviour. Since the previous behaviour was reported as incorrect in #7819 , I was thinking that the default behaviour should become to fail on download error. Before I discovered the behaviour, I was assuming that unresolvable entries for plugins in package.json would cause the build to fail, just like the build fails when we there are unresolvable entries for npm packages in package.json. Also, if we keep the current behaviour of tolerating download failures by default and introduce an flag that users would have to pass to make download failures fatal, then this would not be enough to fix #7819 (we would have to do something such as updating documentation so that user pass the flag)

perrinjerome added a commit to perrinjerome/theia that referenced this pull request Nov 30, 2020
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

I'm not sure I correctly understood the suggestion properly about what should be the default behaviour.

@perrinjerome the default should be to fail the build if there are errors when retrieving plugins (that is why it is marked as a breaking change. This aligns with the expectation from the issue.

dev-packages/cli/src/theia.ts Outdated Show resolved Hide resolved
dev-packages/cli/src/theia.ts Outdated Show resolved Hide resolved
@paul-marechal
Copy link
Member

@perrinjerome I was asking to not change the default behavior and only throw when adding the flag, this way nothing breaks?

@paul-marechal
Copy link
Member

paul-marechal commented Nov 30, 2020

After discussing with @vince-fugnitto it seems to make sense to throw by default, and have a --ignore-errors flag to prevent that. If anyone thinks the script should not throw please say so. This change might break some builds on error now.

@perrinjerome
Copy link
Contributor Author

Thank you for your feedback. I have pushed a new commit to name the flag --ignore-errors / i

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

@perrinjerome thank you for your changes 👍
Please squash your commits (into a single commit) so we can approve and merge :)

@perrinjerome
Copy link
Contributor Author

Thank you, I squashed everything in one commit

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

@perrinjerome it looks like there is currently a conflict with the changelog, please rebase, resolve conflicts and squash if necessary 👍

If something went wrong while downloading plugins, the build should be
interrupted, instead of creating an environment where some plugins might
be missing.

A new --ignore-errors flag is added to retain the previous behavior of
not failing the build in case of download errors.

Signed-off-by: Jérome Perrin <[email protected]>
@perrinjerome perrinjerome force-pushed the fix/download-plugin-error branch from da443ed to 41f3080 Compare December 3, 2020 01:11
@perrinjerome
Copy link
Contributor Author

@vince-fugnitto thanks ! I rebased and resolved conflict on changelog

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

Thank you for the pull-request @perrinjerome!

I verified the following:

  • the script successfully downloads plugins
  • the script successfully reports errors when plugins cannot be fetched
  • the -i or --ignore-errors flag correctly works in suppressing errors

@vince-fugnitto vince-fugnitto merged commit e616c94 into eclipse-theia:master Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theia-cli issues related to the theia-cli
Projects
None yet
Development

Successfully merging this pull request may close these issues.

As an extension developer I want yarn to fail fast if the VS Code extensions cannot be downloaded
3 participants