Skip to content

fix(report): waiting promise resolve in onExist method fix #418#419

Merged
anthony-redFox merged 1 commit intokarma-runner:masterfrom
anthony-redFox:master
Jul 24, 2020
Merged

fix(report): waiting promise resolve in onExist method fix #418#419
anthony-redFox merged 1 commit intokarma-runner:masterfrom
anthony-redFox:master

Conversation

@anthony-redFox
Copy link
Copy Markdown
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
return
}
if (typeof config._onExit === 'function') {
config._onExit(done)
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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