Skip to content

fix: avoid starting a timeout if the timer was resolved immediately#14642

Merged
christian-bromann merged 1 commit intowebdriverio:mainfrom
sheremet-va:fix/timer-resolve-now
Jul 14, 2025
Merged

fix: avoid starting a timeout if the timer was resolved immediately#14642
christian-bromann merged 1 commit intowebdriverio:mainfrom
sheremet-va:fix/timer-resolve-now

Conversation

@sheremet-va
Copy link
Contributor

@sheremet-va sheremet-va commented Jul 14, 2025

Proposed changes

There is a small bug in the timer implementation. If the timer is leading, it can resolve the timer immediately. When it does this, it clears the _timeoutId and _mainTimeoutId, but since if was resolved immediately, the _mainTimeoutId is not created yet.

So, the timeout resolves and always creates a 5 seconds timer which hangs the process. This is especially visible when browser.deleteSession is called.

I debugged this using the same reproduction from #14639, but called destroySession at the end. I expect the process to stop immediately after the promise is resolved, but I always need to wait 5 seconds because the url method started a timeout, but never cleared it.

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

//: # (The current main branch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against the v8 branch.)

  • This change is solely for v9 and doesn't need to be back-ported
  • Back-ported PR at #XXXXX

Further comments

Reviewers: @webdriverio/project-committers

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 14, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

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.

Nice catch 👌

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Jul 14, 2025
@christian-bromann christian-bromann merged commit 3740f39 into webdriverio:main Jul 14, 2025
3 checks passed
@wdio-bot
Copy link
Contributor

Hey sheremet-va 👋

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 🤖

@sheremet-va sheremet-va deleted the fix/timer-resolve-now branch July 14, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants