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 handling of non-offline errors #6968

Merged
merged 3 commits into from Jan 30, 2019
Merged

Fix handling of non-offline errors #6968

merged 3 commits into from Jan 30, 2019

Conversation

yan12125
Copy link
Contributor

Summary

After #6413, some errors from request are not handled as the else part is (accidentally?) removed [1]. Adding it back fixes #6915.

[1] 454986b#diff-5d246f90b159bd84bbc99f67527b1a0eL374

Test plan

I use libfaketime [2] to simulate expired HTTPS certificates. Before the change:

$ faketime -f '+3y' node lib/cli/index.js --verbose add web-ext         
yarn add v1.15.0-0
verbose 0.763 Checking for configuration file "/home/yen/Projects/yarn/.npmrc".
verbose 0.764 Checking for configuration file "/home/yen/.npmrc".
verbose 0.769 Checking for configuration file "/usr/etc/npmrc".
verbose 0.772 Checking for configuration file "/home/yen/Projects/yarn/.npmrc".
verbose 0.773 Checking for configuration file "/home/yen/Projects/.npmrc".
verbose 0.773 Checking for configuration file "/home/yen/.npmrc".
verbose 0.774 Checking for configuration file "/home/.npmrc".
verbose 0.775 Checking for configuration file "/home/yen/Projects/yarn/.yarnrc".
verbose 0.777 Checking for configuration file "/home/yen/.yarnrc".
verbose 0.778 Found configuration file "/home/yen/.yarnrc".
verbose 0.779 Checking for configuration file "/usr/etc/yarnrc".
verbose 0.779 Checking for configuration file "/home/yen/Projects/yarn/.yarnrc".
verbose 0.78 Checking for configuration file "/home/yen/Projects/.yarnrc".
verbose 0.782 Checking for configuration file "/home/yen/.yarnrc".
verbose 0.783 Found configuration file "/home/yen/.yarnrc".
verbose 0.783 Checking for configuration file "/home/.yarnrc".
verbose 0.795 current time: 2022-01-25T19:13:20.359Z
[1/5] Validating package.json...
[2/5] Resolving packages...
verbose 2.053 Performing "GET" request to "https://registry.yarnpkg.com/web-ext".
⠠ web-ext

(the command stuck here)

After the change:

$ faketime -f '+3y' node lib/cli/index.js --verbose add web-ext
yarn add v1.15.0-0
verbose 0.748 Checking for configuration file "/home/yen/Projects/yarn/.npmrc".
verbose 0.752 Checking for configuration file "/home/yen/.npmrc".
verbose 0.753 Checking for configuration file "/usr/etc/npmrc".
verbose 0.754 Checking for configuration file "/home/yen/Projects/yarn/.npmrc".
verbose 0.757 Checking for configuration file "/home/yen/Projects/.npmrc".
verbose 0.757 Checking for configuration file "/home/yen/.npmrc".
verbose 0.76 Checking for configuration file "/home/.npmrc".
verbose 0.761 Checking for configuration file "/home/yen/Projects/yarn/.yarnrc".
verbose 0.762 Checking for configuration file "/home/yen/.yarnrc".
verbose 0.762 Found configuration file "/home/yen/.yarnrc".
verbose 0.764 Checking for configuration file "/usr/etc/yarnrc".
verbose 0.764 Checking for configuration file "/home/yen/Projects/yarn/.yarnrc".
verbose 0.767 Checking for configuration file "/home/yen/Projects/.yarnrc".
verbose 0.769 Checking for configuration file "/home/yen/.yarnrc".
verbose 0.769 Found configuration file "/home/yen/.yarnrc".
verbose 0.77 Checking for configuration file "/home/.yarnrc".
verbose 0.777 current time: 2022-01-25T19:13:59.660Z
[1/5] Validating package.json...
[2/5] Resolving packages...
verbose 2.131 Performing "GET" request to "https://registry.yarnpkg.com/web-ext".
verbose 2.218 Error: certificate has expired
    at TLSSocket.onConnectSecure (_tls_wrap.js:1142:34)
    at TLSSocket.emit (events.js:197:13)
    at TLSSocket._finishInit (_tls_wrap.js:631:8)
error An unexpected error occurred: "https://registry.yarnpkg.com/web-ext: certificate has expired".
info If you think this is a bug, please open a bug report with the information provided in "/home/yen/Projects/yarn/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

With this change and export NODE_TLS_REJECT_UNAUTHORIZED=0:

$ faketime -f '+3y' node lib/cli/index.js --verbose add web-ext                                                                                                       [3/170]
yarn add v1.15.0-0                                                                                                                                                           
verbose 0.764 Checking for configuration file "/home/yen/Projects/yarn/.npmrc".                                                                                              
verbose 0.765 Checking for configuration file "/home/yen/.npmrc".                                                                                                            
verbose 0.766 Checking for configuration file "/usr/etc/npmrc".
verbose 0.767 Checking for configuration file "/home/yen/Projects/yarn/.npmrc".
verbose 0.767 Checking for configuration file "/home/yen/Projects/.npmrc".
verbose 0.767 Checking for configuration file "/home/yen/.npmrc".
verbose 0.768 Checking for configuration file "/home/.npmrc".
verbose 0.77 Checking for configuration file "/home/yen/Projects/yarn/.yarnrc".
verbose 0.77 Checking for configuration file "/home/yen/.yarnrc".
verbose 0.77 Found configuration file "/home/yen/.yarnrc".
verbose 0.771 Checking for configuration file "/usr/etc/yarnrc".
verbose 0.771 Checking for configuration file "/home/yen/Projects/yarn/.yarnrc".
verbose 0.772 Checking for configuration file "/home/yen/Projects/.yarnrc".
verbose 0.772 Checking for configuration file "/home/yen/.yarnrc".
verbose 0.772 Found configuration file "/home/yen/.yarnrc".
verbose 0.773 Checking for configuration file "/home/.yarnrc".
verbose 0.779 current time: 2022-01-25T19:14:56.386Z
[1/5] Validating package.json...
[2/5] Resolving packages...
verbose 2 Performing "GET" request to "https://registry.yarnpkg.com/web-ext".
(node:25176) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
verbose 2.05 Error: https://registry.yarnpkg.com/web-ext: SSL Error: CERT_HAS_EXPIRED
    at Request.onRequestResponse (/home/yen/Projects/yarn/node_modules/request/request.js:948:24)                                                                           
    at ClientRequest.emit (events.js:202:15)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:562:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:113:17)
    at TLSSocket.socketOnData (_http_client.js:449:20)
    at TLSSocket.emit (events.js:197:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:145:17)
error An unexpected error occurred: "https://registry.yarnpkg.com/web-ext: SSL Error: CERT_HAS_EXPIRED".
info If you think this is a bug, please open a bug report with the information provided in "/home/yen/Projects/yarn/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

[2] https://github.com/wolfcw/libfaketime

@yan12125
Copy link
Contributor Author

Hi @arcanis, as you're the author of #6413, could you have a look?

@arcanis
Copy link
Member

arcanis commented Jan 30, 2019

Looks good to me, thanks!

@arcanis arcanis merged commit af91e7c into yarnpkg:master Jan 30, 2019
@yan12125 yan12125 deleted the issue6915 branch January 30, 2019 19:44
erik-singleton pushed a commit to erik-singleton/yarn that referenced this pull request Feb 4, 2019
cacheflow added a commit to cacheflow/yarn that referenced this pull request Feb 14, 2019
* master: (67 commits)
  Include key info for "expected hoisted" invariant (yarnpkg#7009)
  refactor: remove unnecessary checks (yarnpkg#6955)
  fix: drive letter casing for win32 pnp (yarnpkg#7007)
  Don’t call `release` with an exit code (yarnpkg#6981)
  Check os and platform even when engines is not present in package.json (yarnpkg#6976)
  Fix handling of non-offline errors (yarnpkg#6968)
  Treat the ignore-scripts in yarnrc as a synonym to the cli arg (yarnpkg#6983)
  fix(pnp): make sure pnp module is again the first preloaded module. (yarnpkg#6951)
  refactor: remove unused imports (yarnpkg#6956)
  Add 1.14.0 to changelog (yarnpkg#6967)
  1.15.0-0
  v1.14.0
  Fix suggested command after unlinking a package (yarnpkg#6931)
  Update CHANGELOG.md
  fix(pnp): make sure pnp module is the first preloaded module. (yarnpkg#6942)
  fix(pnp): make sure that the package locator is fetched with a trailing slash (yarnpkg#6882)
  Improve rendering of Chocolatey package description (yarnpkg#6899)
  Fixing dynamic require missing from webpack (yarnpkg#6908)
  feat(policies): Use github access token when requesting releases (yarnpkg#6912)
  Fixes PnP detection across workspaces (yarnpkg#6878)
  ...
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.

Yarn silently fails when unable to verify first certificate
2 participants