Skip to content

[🐛 Bug]: @wdio/local-runner exits on SIGINT before cleanup - deleteSession() never called #14609

@DQRI

Description

@DQRI

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.16.2

Node.js Version

22.11.0

Mode

WDIO Testrunner

Which capabilities are you using?

{
            browserName                   : 'chrome',
            'wdio:enforceWebDriverClassic': true,
            'wdio:maxInstances'           : 1,
            'goog:chromeOptions'          : {
                args: [
                    'disable-gpu',
                    'no-sandbox',
                    'window-size=1440,1080',
                    'disable-dev-shm-usage',
                    'disable-notifications',
                    'disable-dev-tools',
                    'disable-translate',
                    'disable-infobars'
                ]
            },
            pageLoadStrategy: 'eager'
        }

What happened?

After migrating from async-exit-hook to exit-hook in #14511, the new exitHook() was used in a way that runs synchronously, causing Node.js to exit before cleanup could complete. As a result, after I press Ctrl+C during a WDIO run, deleteSession() was never called on SIGINT, and browser sessions remained hanging

What is your expected behavior?

When I press Ctrl+C during a WDIO run, I expect the session to be gracefully closed, and the process to exit cleanly with code 130 — not abruptly killed

How to reproduce the bug.

  • Use WebdriverIO v9.16.2
  • Run any WDIO test suite with a valid browser session
  • While the browser is open and test is running, press Ctrl+C to send SIGINT

Result

  • No deleteSession() call is made
  • Node process exits immediately

Relevant log output

^C

Ending WebDriver sessions gracefully ...
(press ctrl+c again to hard kill the runner)
2025-07-01T14:59:07.568Z INFO @wdio/local-runner: Shutting down spawned worker
[0-0] FAILED in chrome - file:///src/test/specs/test.spec.ts
2025-07-01T14:59:07.578Z INFO @wdio/cli:launcher: Run onWorkerEnd hook

Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:04  

2025-07-01T14:59:07.578Z INFO @wdio/cli:launcher: Run onComplete hook

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions