Skip to content

fix(@wdio/runner): Continue emitting event on the runner even when a reporter throws an error#13958

Merged
christian-bromann merged 3 commits intowebdriverio:mainfrom
dprevost-LMI:continue-when-reporter-throws
Dec 9, 2024
Merged

fix(@wdio/runner): Continue emitting event on the runner even when a reporter throws an error#13958
christian-bromann merged 3 commits intowebdriverio:mainfrom
dprevost-LMI:continue-when-reporter-throws

Conversation

@dprevost-LMI
Copy link
Contributor

@dprevost-LMI dprevost-LMI commented Dec 8, 2024

Proposed changes

In this issue, we discovered we could hang the runner process when processing the reporters with specific conditions. Moreover, after a closer look, when the AllureReporter throws an error, it fails the run, stating that some tests failed when this is not the case. Finally, since we can configure multiple reporters, an error thrown by one should not affect the other reporters.

So, to have more robust test runs and make a better effort at finishing reporting, I propose to try-catch the error after emitting the event to a faulty reporter, output the error in the console, continue to the next reporter, and emit the next event.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works

Backport Request

  • This change is solely for v9 and doesn't need to be back-ported

Further comments

Here is an example where the Allure reporter was throwing an error, but the Spec reporter was not. With the fix, we can now see that the run was successful, but Allure has potential problems due to the error. Weirdly, the second picture shows that the Allure reporting was still working despite the error.

image

image

Reviewers: @webdriverio/project-committers

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 8, 2024

Open in Stackblitz

eslint-plugin-wdio

npm i https://pkg.pr.new/webdriverio/webdriverio/eslint-plugin-wdio@13958

@wdio/appium-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/appium-service@13958

@wdio/allure-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/allure-reporter@13958

@wdio/browser-runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/browser-runner@13958

@wdio/browserstack-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/browserstack-service@13958

@wdio/cli

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/cli@13958

@wdio/concise-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/concise-reporter@13958

@wdio/config

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/config@13958

@wdio/cucumber-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/cucumber-framework@13958

@wdio/dot-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/dot-reporter@13958

@wdio/firefox-profile-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/firefox-profile-service@13958

@wdio/globals

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/globals@13958

@wdio/jasmine-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/jasmine-framework@13958

@wdio/json-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/json-reporter@13958

@wdio/junit-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/junit-reporter@13958

@wdio/lighthouse-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/lighthouse-service@13958

@wdio/logger

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/logger@13958

@wdio/local-runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/local-runner@13958

@wdio/mocha-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/mocha-framework@13958

@wdio/protocols

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/protocols@13958

@wdio/repl

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/repl@13958

@wdio/reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/reporter@13958

@wdio/runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/runner@13958

@wdio/sauce-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/sauce-service@13958

@wdio/shared-store-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/shared-store-service@13958

@wdio/smoke-test-cjs-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-cjs-service@13958

@wdio/smoke-test-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-reporter@13958

@wdio/smoke-test-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-service@13958

@wdio/spec-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/spec-reporter@13958

@wdio/static-server-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/static-server-service@13958

@wdio/sumologic-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/sumologic-reporter@13958

@wdio/testingbot-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/testingbot-service@13958

@wdio/types

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/types@13958

@wdio/utils

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/utils@13958

@wdio/webdriver-mock-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/webdriver-mock-service@13958

webdriver

npm i https://pkg.pr.new/webdriverio/webdriverio/webdriver@13958

webdriverio

npm i https://pkg.pr.new/webdriverio/webdriverio@13958

commit: 088700e

@dprevost-LMI dprevost-LMI changed the title Continue emitting event on the runner even when a reporter throws an error fix(@wdio/runner): Continue emitting event on the runner even when a reporter throws an error Dec 8, 2024
@dprevost-LMI dprevost-LMI marked this pull request as ready for review December 8, 2024 13:49
@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Dec 9, 2024
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Great work 👏

@christian-bromann christian-bromann merged commit 8743d1b into webdriverio:main Dec 9, 2024
@wdio-bot
Copy link
Contributor

wdio-bot commented Dec 9, 2024

Hey dprevost-LMI 👋

Thank you for your contribution to WebdriverIO! Your pull request has been marked as an "Expensable" contribution.

We've sent you an email with further instructions on how to claim your expenses from our development fund.
Please make sure to check your spam folder as well. If you have any questions, feel free to reach out to us at expense@webdriver.io or in the contributing channel on Discord.

We are looking forward to more contributions from you in the future 🙌

Have a nice day,
The WebdriverIO Team 🤖

@wdio-bot
Copy link
Contributor

Hey dprevost-LMI 👋

Thank you for your contribution to WebdriverIO! Your pull request has been marked as an "Expensable" contribution.

We've sent you an email with further instructions on how to claim your expenses from our development fund.
Please make sure to check your spam folder as well. If you have any questions, feel free to reach out to us at expense@webdriver.io or in the contributing channel on Discord.

We are looking forward to more contributions from you in the future 🙌

Have a nice day,
The WebdriverIO Team 🤖

@dprevost-LMI dprevost-LMI deleted the continue-when-reporter-throws branch June 8, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Expensable $50 💸 PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants