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(report): waiting promise resolve in onExist method fix #418 #419

Merged
merged 1 commit into from
Jul 24, 2020

Conversation

anthony-redFox
Copy link
Collaborator

onComplete are async method which should bw complete in onExit method

@anthony-redFox anthony-redFox force-pushed the master branch 2 times, most recently from 3d5372e to 9bc1103 Compare July 22, 2020 16:59
…er#418

onComplete are async method which should bw complete in onExit method
lib/reporter.js Show resolved Hide resolved
if (results && results.exitCode === 1) {
done(results.exitCode)
return
}
if (typeof config._onExit === 'function') {
config._onExit(done)
Copy link

Choose a reason for hiding this comment

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

Not sure where this function gets defined or where it's used, but it won't be called in case exitCode is 1.
See #420 for my approach, which still calls it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you sure that will be useful to call callback onExit? custom code can call with 1 or 0 too but you are ignore it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Build will be failed. Is matter to execute onExit method?

Copy link

Choose a reason for hiding this comment

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

I don't know where _onExit is defined or used, but with this change it's not called anymore in case the exitCode is 1. That's what I wanted to note here.

}

this.onExit = async function (done) {
const results = await promiseComplete
Copy link

Choose a reason for hiding this comment

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

There is no error handling by karma in case promiseComplete rejects. Karma doesn't expect the onExit handlers to return a promise. I would suggest using plain old then to handle success/error. See my code in #420

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

await works with success only, if will be error the code onExit will be failed

Copy link

Choose a reason for hiding this comment

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

onExit is called sync by the karma-runner and expects the callback to be invoked. It doesn't expect a promise to be returned. That's why I suspect that a rejection would result into an unhandled Promise rejection.

@anthony-redFox anthony-redFox merged commit 9648882 into karma-runner:master Jul 24, 2020
@karmarunnerbot
Copy link
Member

🎉 This PR is included in version 2.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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