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

ENHANCEMENT: update-checker.js should use environment http_proxy if detected #3488

Merged
merged 4 commits into from
Mar 18, 2015

Conversation

xomaczar
Copy link
Contributor

I am working behind corporate proxy and every command I provide to ember-cli (except test & update) result in an error without ability to proceed/recover.

@@ -53,7 +53,8 @@ function cli(options) {
};

var defaultUpdateCheckerOptions = {
checkForUpdates: true
checkForUpdates: true,
httpProxy: process.env['http_proxy']
Copy link
Contributor

Choose a reason for hiding this comment

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

our convention is all caps for env vars.

@rwjblue r?

Copy link
Contributor

Choose a reason for hiding this comment

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

although the npm settings seem to be lower-case. Is it possible for us to read these settings via npm as a lib?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, agree. I'll check into that.

@stefanpenner
Copy link
Contributor

@xomaczar CI seems to not agree with this PR yet.

@stefanpenner stefanpenner self-assigned this Mar 10, 2015
});
}).then(function(version) {

}.bind(this)).then(function(version) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this one? I am accessing this.settings.httpProxy, although it can be moved out where bind(this) will not be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stefanpenner I ran npm test as described in docs before making this PR. All tests were passing. I'll look into that as well

Copy link
Contributor

Choose a reason for hiding this comment

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

npm test is only the fast tests, npm run test-all includes the slow acceptance tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

updated docs: 5788bdb

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great

@xomaczar
Copy link
Contributor Author

@stefanpenner I need help, I ran npm run test-all, everything passed, except 2 pending. I squashed my changes, but PR does not reflect that.

@rwjblue
Copy link
Member

rwjblue commented Mar 12, 2015

This is failing because the latest testem version (0.7.4) is missing a dependency. I submitted testem/testem#515 to fix this upstream.

@johanneswuerbach
Copy link
Contributor

Testem 0.7.5 includes the fix, sorry about that.

@stefanpenner
Copy link
Contributor

missing }).then(....

where?

}));

res.on('error', reject);
npm.load(npmViewConfig, function(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can use denodeify https://github.com/ember-cli/ember-cli/blob/master/lib/ext/promise.js#L13-L21
docs: https://github.com/tildeio/rsvp.js/blob/master/lib/rsvp/node.js#L73-L201

var load  = Promise.denodeify(npm.load);
var view = Promise.denodeify(npm.commans.view);

now stuff is all promisey and wonderful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Promisey it is. Update to follow

Copy link
Contributor

Choose a reason for hiding this comment

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

<3

Copy link
Contributor

Choose a reason for hiding this comment

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

let me know :)

@xomaczar
Copy link
Contributor Author

@stefanpenner would u like for me to squash those 3 commits

return this.saveVersionInformation(version);
}.bind(this))
.catch(function(error) {
this.ui.writeLine('There was an error checking NPM for an update: ' + error);
Copy link
Contributor

Choose a reason for hiding this comment

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

we have a this.ui.writeError, but the throw should handle that already, i suspect only the error.message is needed her.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stefanpenner you mean just this.ui.writeLine(e.message)? I haven't looked at the calling code, but according to your statement we're catching all rejections upstream, do we even need catch here?

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/ember-cli/ember-cli/blob/master/lib/ui/index.js#L84-L93

which gets called for any error throw: https://github.com/ember-cli/ember-cli/blob/master/lib/cli/cli.js#L98
via: https://github.com/ember-cli/ember-cli/blob/master/lib/cli/cli.js#L136-L143

I believe, we just need error && typeof error === 'object' && error.message || '' no need in printing the error twice if it happens

@rwjblue r ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why are we trying to catch those errors/rejections in https://github.com/xomaczar/ember-cli/blob/master/lib/models/update-checker.js#L86-L89.
The only way any of the those promises get rejected is if any errors are thrown inside then()s, we don't explicitly reject() anything in any then(...). Let's just https://github.com/ember-cli/ember-cli/blob/master/lib/cli/cli.js#L98 catch and log it.
i.e. I am suggesting to remove the catch() in update-checker.js and let the error bubble up.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes that sounds correct

@stefanpenner
Copy link
Contributor

@xomaczar not a big deal, i left one suggestion, then i think we are good to go.

@xomaczar
Copy link
Contributor Author

@stefanpenner There is one case where updatechecker will still throw exception, therefore stopping any command execution with getaddrinfo error.
if settings.checkForUpdates && configstore/ember-cli-version:lastVersionCheckAt > 1day && npm cache clean && no internet connection
updateChecker should fail in that case, report the issue to the user "Failed to check for updates" and continue execution. Updates notification is nice to have, but when it block people from running their app, it become a nuisance! Thoughts?

@stefanpenner
Copy link
Contributor

@xomaczar so just log and message and more on if that is the error we see? Actually, maybe this should never re-throw and always just log and error but handle the rejection. It does seem silly that updateChecker could stop someone from developing.

@stefanpenner
Copy link
Contributor

cc @twokul

@xomaczar
Copy link
Contributor Author

Agree just catch log, but don't re-throw, tne promise gets resolved, user sees the issue but able to continue...Hopefully last change

@stefanpenner
Copy link
Contributor

@xomaczar thanks for working through all these changes with us :) Let me know when you think its good for another review, and yes lets hope to get it in asap :)

@twokul
Copy link
Contributor

twokul commented Mar 17, 2015

@xomaczar @stefanpenner I assume this got resolved?

@xomaczar
Copy link
Contributor Author

@stefanpenner happy to be involved. Try to push it in tonight.
@twokul one more commit and we should be good to go

@stefanpenner
Copy link
Contributor

@stefanpenner happy to be involved. Try to push it in tonight.

👍 we are happy to have you involved, feel free to share feedback to help us all make contributing better.

@xomaczar
Copy link
Contributor Author

@stefanpenner ready for another review
cc @twokul

stefanpenner added a commit that referenced this pull request Mar 18, 2015
ENHANCEMENT: update-checker.js should use environment http_proxy if detected
@stefanpenner stefanpenner merged commit 19a7eb0 into ember-cli:master Mar 18, 2015
@stefanpenner
Copy link
Contributor

👍

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.

None yet

5 participants