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(@embark/core): don't exit in Engine consumer API #2087

Merged
merged 1 commit into from Nov 29, 2019

Conversation

0x-r4bbit
Copy link
Contributor

Engine.startEngine(cb) potentially exits the current process if
any registered plugins emits an error in the bootstrap phase.

This limits consumers of this API to react accordingly. Embark's APIs
should be considered library APIs that propagate errors, but let callers
decide what to do with them.

This commit ensures we keep propagating the error of startEngine() without
exiting the current process.

@ghost
Copy link

ghost commented Nov 26, 2019

DeepCode Report (#df671f)

DeepCode analyzed this pull request.
There are no new issues.

return callback(err);
} else {
callback();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some thoughts to consider for the future and potentially #2028 :

While startEngine() takes a callback to inform its caller when it's "ready" it actually also triggers actions (e.g. spinning up cockpit etc). In fact, the "only" thing startEngine() does is running actions for plugins if they are registered. If there's no plugins, it'll just call its given callback.

Then, OTOH, compilation and deployment is done only as part of this particular callback (see line 209-210).

Might be worth considering renaming startEngine() to something more appropriate, if it really only triggers plugin actions.

Food for thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To add to that: it even so happens that (right now) all embark:engine:started actions are being registered inside the cmd_controller which should probably rather happen in the dedicated modules.

engine.logger.info(err.stack);
} else {
engine.logger.error(err);
}
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 check here is needed because sometimes we're getting an actual Error sometimes we're getting just a string (error message).

Hopefully in the future we have this streamlined and always emit a proper error type (see #911)

engine.startEngine(async (err) => {
if (err) {
return callback(err);
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can remove the else since you return in the if

`Engine.startEngine(cb)` potentially exits the current process if
any registered plugins emits an error in the bootstrap phase.

This limits consumers of this API to react accordingly. Embark's APIs
should be considered library APIs that propagate errors, but let callers
decide what to do with them.

This commit ensures we keep propagating the error of `startEngine()` without
exiting the current process.
@0x-r4bbit 0x-r4bbit merged commit a7edca0 into master Nov 29, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix/engine-error-handling branch November 29, 2019 11:57
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

3 participants