Skip to content

Avoid using process.exit as we need to flush telemetry #8873

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
Mar 28, 2022

Conversation

mads-hartmann
Copy link
Contributor

Description

We don't always get traces from gitpod-io/gitod when the main build fails (see https://github.com/gitpod-io/ops/issues/865 for more context).

We're relying on Node's beforeExit event to ensure that we flush our traces before stopping the node process (see here). This means that we can't use process.exit in our TS scripts, as that doesn't invoke the beforeExit handlers.

We have previously gotten rid of process.exit invocations but had overlooked one. This PR removes it. Previously reportBuildFailureInSlack took an onErr function which it invoked once the request to slack completed (or failed). We passed in () => process.exit(1). I've removed the onErr argument and converted it to a promise-based API instead. We now don't do anything if the Slack requests succeeds but do log the error if it fails. The process.exitCode is moved out of the else-branch so it's always set if the build fails.

Related Issue(s)

Fixes https://github.com/gitpod-io/ops/issues/865

How to test

I haven't tested this as I couldn't find an easy way to test it. Given the code change is rather trivial (though that can be deceiving) I'm happier merging and reverting if it turns out I broke the Slack notification ☺️

Release Notes

NONE

Documentation

N/A

@mads-hartmann
Copy link
Contributor Author

mads-hartmann commented Mar 17, 2022

@geropl I requested review from you as well you have touched this code before ☺️

Copy link
Contributor

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

/hold

LGTM, but I'm adding a hold in case you're waiting for Gero's review

@roboquat roboquat merged commit 2c02568 into main Mar 28, 2022
@roboquat roboquat deleted the mads/dont-use-process-exit branch March 28, 2022 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants