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

Show problem path in invariant message #6868

Merged
merged 1 commit into from
Jan 4, 2019

Conversation

CGamesPlay
Copy link
Contributor

@CGamesPlay CGamesPlay commented Jan 2, 2019

Summary

Sometimes, yarn add will fail unexpectedly, and it leaves the cache in an invalid state. To cause your yarn cache to become corrupted:

$ yarn add [email protected]
yarn add v1.12.3
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.6.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "Unexpected end of data"
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

$ yarn cache list
yarn cache v1.12.3
error An unexpected error occurred: "There should only be one folder in a package cache (got  )".
info If you think this is a bug, please open a bug report with the information provided in "/Users/rpatterson/Projects/chess2/www2/client/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/cache for documentation about this command.

Note that the error message provides no information about how to resolve the error. This commit adds the problem path to the invariant message. Deleting this problem path will allow yarn cache list to work properly again.

The root cause of this issue is #6805 which has been closed. This commit does not resolve the issue, so that issue should likely be reopened.

Test plan

Simply running yarn cache list while the cache is in an invalid state as described above produces a more useful error message.

Sometimes, `yarn add` will fail unexpectedly, and it leaves the cache in an invalid state. To cause your yarn cache to become corrupted:

```
$ yarn add [email protected]
yarn add v1.12.3
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.6.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "Unexpected end of data"
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

$ yarn cache list
yarn cache v1.12.3
error An unexpected error occurred: "There should only be one folder in a package cache (got  )".
info If you think this is a bug, please open a bug report with the information provided in "/Users/rpatterson/Projects/chess2/www2/client/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/cache for documentation about this command.
```

Note that the error message provides no information about how to resolve the error. This commit adds the problem path to the invariant message. Deleting this problem path will allow `yarn cache list` to work properly again.

The root cause of this issue is yarn#6805 which has been closed. This commit does not resolve the issue, so that issue should likely be reopened.
@CGamesPlay
Copy link
Contributor Author

Update: apparently my repro steps are invalid in a clean repository, so one of my other dependencies, [email protected], was dependent on event-stream. However, [email protected] seems to have been unpublished so the repro doesn't work. Still, the patch is seems useful.

@arcanis
Copy link
Member

arcanis commented Jan 4, 2019

Looks good to me, thanks 🙂

@arcanis arcanis merged commit b1f21a8 into yarnpkg:master Jan 4, 2019
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.

2 participants