Skip to content

desktopCapturer tests are flaky on macos-x64 #51124

Closed

Description

@nikwen

Confirmation

Description

The desktopCapturer tests are flaky on macos-x64 in CI (both darwin and mas).

Logs

Failure in test: "desktopCapturer should return a non-empty array of sources"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (1/3)...
Failure in test: "desktopCapturer should return a non-empty array of sources"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (2/3)...
Failure in test: "desktopCapturer should return a non-empty array of sources"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (3/3)...
not ok 78 desktopCapturer should return a non-empty array of sources
  Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
  Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
      at listOnTimeout (node:internal/timers:605:17)
      at processTimers (node:internal/timers:541:7)
ok 79 desktopCapturer throws an error for invalid options
Failure in test: "desktopCapturer does not throw an error when called more than once (regression)"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (1/3)...
Failure in test: "desktopCapturer does not throw an error when called more than once (regression)"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (2/3)...
Failure in test: "desktopCapturer does not throw an error when called more than once (regression)"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (3/3)...
not ok 80 desktopCapturer does not throw an error when called more than once (regression)
  Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
  Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
      at listOnTimeout (node:internal/timers:605:17)
      at processTimers (node:internal/timers:541:7)
Failure in test: "desktopCapturer responds to subsequent calls of different options"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (1/3)...
Failure in test: "desktopCapturer responds to subsequent calls of different options"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (2/3)...
Failure in test: "desktopCapturer responds to subsequent calls of different options"
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
    at createTimeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/errors.js:498:15)
    at Test.Runnable._timeoutError (/Users/runner/work/electron/electron/src/electron/spec/node_modules/mocha/lib/runnable.js:429:10)
Retrying test (3/3)...
not ok 81 desktopCapturer responds to subsequent calls of different options
  Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
  Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/runner/work/electron/electron/src/electron/spec/api-desktop-capturer-spec.ts)
      at listOnTimeout (node:internal/timers:605:17)
      at processTimers (node:internal/timers:541:7)
ok 82 desktopCapturer returns an empty display_id for window sources
ok 83 desktopCapturer returns display_ids matching the Screen API
ok 84 desktopCapturer enabling thumbnail should return non-empty images
ok 85 desktopCapturer disabling thumbnail should return empty images
ok 86 desktopCapturer getMediaSourceId should match DesktopCapturerSource.id
ok 87 desktopCapturer getSources should not incorrectly duplicate window_id
ok 88 desktopCapturer does not affect window resizable state
ok 89 desktopCapturer moveAbove should move the window at the requested place

Example runs:

When investigating, look at the full macos-x64 test logs and search for desktopCapturer. You will see lots of timeouts.

CC @ckerr who recently did work trying to fix desktopCapturer tests.

Activity

  1. added
    ci-flake ⭕️
    on Apr 17, 2026
  2. added theissue type on Apr 17, 2026
  3. moved this to 👀 Unsorted Items in 42-x-yon Apr 17, 2026
  4. nikwen commented on Apr 17, 2026

    @nikwen
    MemberAuthor

    Given that these time out, I assume that the promise returned by desktopCapturer.getSources() never resolves.

  5. nikwen commented on Apr 17, 2026

    @nikwen
    MemberAuthor

    It seems like this is the PR where it started happening: #51068

    When I look at the CI runs for all commits on main, the timeouts did not occur before this PR.

    They happened on every commit after this PR.

  6. nikwen commented on Apr 17, 2026

    @nikwen
    MemberAuthor

    It's not obvious at first sight why that PR would be causing these timeouts.

    Just some ideas:

    • I wonder if closing the BrowserWindows / destroying the webContents in those tests would fix it.
    • I see that many of the other tests in api-media-handler-spec.ts operate on a random session. I wonder if that would help.
  7. self-assigned this
    on Apr 17, 2026
  8. nikwen commented on Apr 17, 2026

    @nikwen
    MemberAuthor

    This seems to be the real root cause: #51125

    I noticed that the order in which tests were run changed after #51068. Maybe some side effect of another test made the tests work before. Then the change in order broke them.

  9. ckerr commented on Apr 17, 2026

    @ckerr
    Member

    @nikwen should this be closed as superseded by #51125 ?

  10. nikwen commented on Apr 17, 2026

    @nikwen
    MemberAuthor

    We can do that. :)

  11. moved this from 👀 Unsorted Items to 🛠️ Fixed for Next Release in 42-x-yon Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

42-x-ybug 🪲ci-flake ⭕️component/desktopcapturerplatform/macOS

Type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions