Page MenuHomePhabricator

Upgrading to webdriver 9 gives "Error: TypeError: Cannot convert undefined or null to object"
Open, HighPublicBUG REPORT

Description

For a couple reprository an upgrade gives the following error:

Error: TypeError: Cannot convert undefined or null to object

I haven't been able to pinpoint if the root cause is in core or in the extension. One thing I've been trying to look for is if the browser object is used before it's initilized but no luck. The problem Is also that I do not get this error when I tried in QuickStart, but get it in CI.

Here are some extensions with that problem:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Popups/+/1156609

Looking at the trace:

11:16:50 [0-0] 2025-06-12T09:16:50.292Z ERROR @wdio/runner: Error: Unable to load spec files quite likely because they rely on `browser` object that is not fully initialized.
11:16:50 [0-0] `browser` object has only `capabilities` and some flags like `isMobile`.
11:16:50 [0-0] Helper files that use other `browser` commands have to be moved to `before` hook.
11:16:50 [0-0] Spec file(s): file:///workspace/src/extensions/Newsletter/tests/selenium/specs/basic.js
11:16:50 [0-0] Error: TypeError: Cannot convert undefined or null to object
11:16:50 [0-0]     at exports.unloadFile (/workspace/src/extensions/Newsletter/node_modules/mocha/lib/nodejs/file-unloader.js:14:32)
11:16:50 [0-0]     at Mocha.unloadFile (/workspace/src/extensions/Newsletter/node_modules/mocha/lib/mocha.js:476:44)
11:16:50 [0-0]     at /workspace/src/extensions/Newsletter/node_modules/mocha/lib/mocha.js:504:11
11:16:50 [0-0]     at Array.forEach (<anonymous>)
11:16:50 [0-0]     at Mocha.unloadFiles (/workspace/src/extensions/Newsletter/node_modules/mocha/lib/mocha.js:503:14)
11:16:50 [0-0]     at Suite.<anonymous> (/workspace/src/extensions/Newsletter/node_modules/@wdio/mocha-framework/build/index.js:194:43)
11:16:50 [0-0]     at Suite.emit (node:events:524:28)
11:16:50 [0-0]     at Suite.emit (node:domain:489:12)
11:16:50 [0-0]     at /workspace/src/extensions/Newsletter/node_modules/mocha/lib/mocha.js:455:13
11:16:50 [0-0]     at exports.loadFilesAsync (/workspace/src/extensions/Newsletter/node_modules/mocha/lib/nodejs/esm-utils.js:104:5)
11:16:50 [0-0]     at MochaAdapter._loadFiles (/workspace/src/extensions/Newsletter/node_modules/@wdio/mocha-framework/build/index.js:214:29)
11:16:50 [0-0]     at async MochaAdapter.init (/workspace/src/extensions/Newsletter/node_modules/@wdio/mocha-framework/build/index.js:195:5)
11:16:50 [0-0]     at async Object.adapterFactory.init (/workspace/src/extensions/Newsletter/node_modules/@wdio/mocha-framework/build/index.js:334:20)

The problem happens when it tried to load spes file and the file gets an TypeError: Cannot convert undefined or null to object. I think that error happens within core the we use our API code, but there's no good stack trace.

Event Timeline

Peter renamed this task from Upgrading to weebdriver 9 gives "Error: TypeError: Cannot convert undefined or null to object" to Upgrading to webdriver 9 gives "Error: TypeError: Cannot convert undefined or null to object".Jun 12 2025, 4:40 PM
Peter added a subscriber: zeljkofilipin.

I've been trying the newsletter patch in quickstart:

 ./fresh_install
GERRIT_PATCHES="refs/changes/76/1156276/1" ./install extensions/Newsletter
./run_component_selenium_tests extensions/Newsletter
....
Execution of 1 workers started at 2025-06-13T05:13:53.474Z

[0-0] RUNNING in chrome - file:///tests/selenium/specs/basic.js
[0-0] PASSED in chrome - file:///tests/selenium/specs/basic.js

 "spec" Reporter:
------------------------------------------------------------------
[chrome 137.0.7151.70 linux #0-0] Running: chrome (v137.0.7151.70) on linux
[chrome 137.0.7151.70 linux #0-0] Session ID: b841c36fe2266fb4f2da74956560e27b
[chrome 137.0.7151.70 linux #0-0]
[chrome 137.0.7151.70 linux #0-0] » tests/selenium/specs/basic.js
[chrome 137.0.7151.70 linux #0-0] Newsletter
[chrome 137.0.7151.70 linux #0-0]    ✓ page should exist on installation
[chrome 137.0.7151.70 linux #0-0]
[chrome 137.0.7151.70 linux #0-0] 1 passing (1.5s)
Spec Files:	 1 passed, 1 total (100% completed) in 00:00:17

This seems to have been related to when npm.js was down. It happened the same day, and after then these kind of errors stopped happening. I don't fully understand what has happened though.

zeljkofilipin changed the subtype of this task from "Task" to "Bug Report".Jun 17 2025, 4:52 PM
zeljkofilipin updated the task description. (Show Details)
zeljkofilipin updated the task description. (Show Details)

Do you know to which repository or commit was this job connected to? The job is now deleted.

There seems to be several problems in several repositories listed in the task. I recommend we split this task per repository and per problem. We can make the decision during office hours meeting next week.

After discussing it with @Peter we agreed he will update the task.

In the beginning we had many repos with this problem, but right now only one. I think we should keep this open though until we upgraded more repos so we can keep track of if this is a generic thing.

Peter removed Peter as the assignee of this task.Jul 1 2025, 3:17 PM
Peter moved this task from In Progress to Backlog on the Test-Platform (ok (Current Sprint)) board.
zeljkofilipin added a subscriber: AMarkossyan-WMF.

Unassigning from @AMarkossyan-WMF since we're not working on this. @AMarkossyan-WMF please add it to the Test-Platform if we plan to work on this any time soon.