Skip to content

Do not break CLI process in case analytics fail #3197

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

Merged
merged 1 commit into from
Nov 7, 2017

Conversation

rosen-vladimirov
Copy link
Contributor

In case we are unable to start the Analytics Broker process, CLI will fail. But analytics errors should not break user's workflow, so catch the error and ensure the actions will continue.
Add tests to verify the behavior.

Also limit the waiting for broker to start to 10 seconds.

const helpers = require("../../../lib/common/helpers");
const originalIsInteractive = helpers.isInteractive;

const trackFeatureUsage = "TrackFeatureUsage";
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be extracted to constants and reused in here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I disagree - the purpose here is to use it for the tests, it could easily be named in other way.

broker.unref();

let isSettled = false;
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe this try { ... } catch (ex) { ... } statement will manage to actually catch anything. More likely you'd get an unhandled rejection if something throws inside the new Promise

const originalSetTimeout = setTimeout;
childProcess.spawn = (command: string, args?: string[], options?: any): any => {
opts.isChildProcessSpawned = true;
const spawnedProcess = new EventEmitter();
Copy link
Contributor

Choose a reason for hiding this comment

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

Getting this spawnedProcess can be extracted into a function - along with setting its stdout, stderr and unref methods

@dtopuzov
Copy link
Contributor

dtopuzov commented Nov 6, 2017

run ci

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/analytics-do-not-fail branch from 552abaf to f0bbdc7 Compare November 7, 2017 10:54
In case we are unable to start the Analytics Broker process, CLI will
fail. But analytics errors should not break user's workflow, so catch the
error and ensure the actions will continue. Add tests to verify the
behavior.
@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/analytics-do-not-fail branch from f0bbdc7 to 1215d43 Compare November 7, 2017 11:44
Copy link
Contributor

@Mitko-Kerezov Mitko-Kerezov left a comment

Choose a reason for hiding this comment

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

Looks okay to me

@rosen-vladimirov rosen-vladimirov merged commit ec6d540 into master Nov 7, 2017
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/analytics-do-not-fail branch November 7, 2017 14:08
rosen-vladimirov added a commit that referenced this pull request Nov 13, 2017
In case we are unable to start the Analytics Broker process, CLI will
fail. But analytics errors should not break user's workflow, so catch the
error and ensure the actions will continue. Add tests to verify the
behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants