Script evaluation can fail with "Error: Missing stack, unable to build exceptionDetails for exception: Error: <text>"
Categories
(Remote Protocol :: WebDriver BiDi, defect, P2)
Tracking
(Not tracked)
People
(Reporter: whimboo, Unassigned)
References
Details
(Whiteboard: [webdriver:m16])
Seen when running the Playwright test page/page-wait-for-function.spec.ts :: should fail with predicate throwing on first call
. It sends the following command:
const error = await page.waitForFunction(() => { throw new Error('oh my'); }).catch(e => e);
But it fails with the following error:
pw:browser [pid=38495][out] 1736260595242 RemoteAgent DEBUG WebDriverBiDiConnection 7e4ef27d-1e2e-4f9e-8bbe-c1760087782d -> {"id":285,"method":"script.callFunction","params":{"functionDeclaration":"(utilityScript, ...args) => utilityScript.evaluate(...args)","target":{"context":"fdfb3306-09bb-4486-ade8-b550d3fe8254"},"arguments":[{"handle":"e5763a55-d623-4197-8b5d-336ed8499e4f"},{"type":"boolean","value":true},{"type":"boolean","value":false},{"type":"string","value":"h => h.result"},{"type":"number","value":2},{"type":"object","value":[[{"type":"string","value":"h"},{"type":"number","value":0}]]},{"type":"object","value":[[{"type":"string","value":"v"},{"type":"string","value":"undefined"}]]},{"handle":"9b7aa5ad-ed9d-4b8b-8224-a42bd5c72776"}],"resultOwnership":"root","serializationOptions":{"maxObjectDepth":0,"maxDomDepth":0},"awaitPromise":true,"userActivation":true}} +0ms
pw:browser [pid=38495][out] 1736260595242 RemoteAgent TRACE Received command script.callFunction for destination ROOT +0ms
pw:browser [pid=38495][out] 1736260595242 RemoteAgent TRACE Received command script.callFunctionDeclaration for destination WINDOW_GLOBAL +0ms
pw:browser [pid=38495][out] 1736260595242 RemoteAgent DEBUG WebDriverBiDiConnection 7e4ef27d-1e2e-4f9e-8bbe-c1760087782d <- {"type":"error","id":285,"error":"unknown error","message":"Error: Missing stack, unable to build exceptionDetails for exception: Error: oh my","stacktrace":"#buildExceptionDetails@chrome://remote/content/webdriver-bidi/modules/windowglobal/script.sys.mjs:77:13\n#buildReturnValue@chrome://remote/content/webdriver-bidi/modules/windowglobal/script.sys.mjs:178:54\n"} +0ms
Due to some reason we do not have a stack. Maybe it's due to the utilityScript that is getting evaluated here.
Reporter | ||
Updated•6 months ago
|
Reporter | ||
Comment 1•6 months ago
|
||
Another test that runs the following seems to work fine:
await page.goto(server.EMPTY_PAGE);
const messages = [];
page.on('console', msg => {
if (msg.text().startsWith('waitForFunction'))
messages.push(msg.text());
});
await page.waitForFunction(() => {
console.log('waitForFunction1');
throw new Error('waitForFunction1');
}).catch(e => null);
Testing further it shows that this is happening when not having a page loaded but running the command on about:blank
.
Reporter | ||
Comment 2•6 months ago
|
||
We probably should have to return an empty stack when we fail to built one.
Reporter | ||
Updated•3 months ago
|
Reporter | ||
Comment 3•2 months ago
|
||
Some commit in the following mozilla-central merge fixed this bug:
Sadly I'm not able to bisect further because of an error with git bisect
.
Julian, given that you are still using Mercurial would you have a chance to check what helped here? We didn't land anything here.
Reporter | ||
Comment 4•2 months ago
|
||
Ok, so I got it working with git by using old
and new
. But this doesn't then work immediately with Playwright and older Firefox versions because in Firefox 137 we haven't implemented user context
support for the browsingContext.setViewport
command. So using an older Playwright version will be necessary to accurately check for the fix.
When I run the bisect now I get the following revision pointed out:
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[55472d0fd4ac1a6affaa3f861a4c3e46c3f6d6e8] Bug 1940952 - [webdriver-bidi] Add support for "userContexts" argument to "browsingContext.setViewport" command. r=webdriver-reviewers,jdescottes
This is still strange because it has nothing to do with the error stack. I would suggest to just mark it as WFM.
Reporter | ||
Updated•2 months ago
|
Description
•