Closed Bug 1940260 Opened 6 months ago Closed 2 months ago

Script evaluation can fail with "Error: Missing stack, unable to build exceptionDetails for exception: Error: <text>"

Categories

(Remote Protocol :: WebDriver BiDi, defect, P2)

defect
Points:
2

Tracking

(Not tracked)

RESOLVED WORKSFORME

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.

Summary: "Error: Missing stack, unable to build exceptionDetails for exception: Error: <text>" → Script evaluation can fail with "Error: Missing stack, unable to build exceptionDetails for exception: Error: <text>"

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.

We probably should have to return an empty stack when we fail to built one.

Severity: -- → S3
Points: --- → 2
Priority: -- → P2
Whiteboard: [webdriver:m15]
Whiteboard: [webdriver:m15] → [webdriver:m16]

Some commit in the following mozilla-central merge fixed this bug:

https://hg-edge.mozilla.org/mozilla-central/pushloghtml?&fromchange=1d513d30adbd2e89c826c9ce540ee2e83104ca73&tochange=97fe6a90f114eebeaec0e1c466dcdcc554eb1d3b

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.

Flags: needinfo?(jdescottes)

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.

Status: NEW → RESOLVED
Closed: 2 months ago
Flags: needinfo?(jdescottes)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.