Closed Bug 1880160 Opened 1 year ago Closed 1 year ago

Handler function threw an exception: TypeError: channel.visitRequestHeaders is not a function

Categories

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

defect
Points:
1

Tracking

(firefox-esr115 unaffected, firefox122 unaffected, firefox123 unaffected, firefox124 fixed, firefox125 fixed)

RESOLVED FIXED
125 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox122 --- unaffected
firefox123 --- unaffected
firefox124 --- fixed
firefox125 --- fixed

People

(Reporter: whimboo, Assigned: jdescottes)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [webdriver:m10])

Attachments

(1 file)

Running the following code in the WebDriver BiDi client results in an error within the NetworkUtils.sys.mjs module.

async function evaluate(context, expression, options = {}) {
  const { awaitPromise = true } = options;

  const res = await sendCommand("script.evaluate", {
    expression,
    target: { context },
    awaitPromise,
  });

  return res.result.result;
}

function sleep(time = 1000) {
  return new Promise(resolve => window.setTimeout(resolve, time));
}

(async function () {
  await sendCommand("session.new", { capabilities: {} });
  let res = await sendCommand("browsingContext.getTree", {});
  let context = res.result.contexts[0].context;

  await sendCommand("session.subscribe", { events: ["network"] });

  await sendCommand("browsingContext.navigate", {
    context,
    url: "https://self-signed.badssl.com/",
    wait: "none",
  });

  await sleep(5000);
})()

The error as raised:

Handler function threw an exception: TypeError: channel.visitRequestHeaders is not a function
Stack: fetchRequestHeadersAndCookies@resource://devtools/shared/network-observer/NetworkUtils.sys.mjs:411:11
NetworkEventRecord@chrome://remote/content/shared/listeners/NetworkEventRecord.sys.mjs:63:25
#onNetworkEvent@chrome://remote/content/shared/listeners/NetworkListener.sys.mjs:101:12
#createNetworkEvent@resource://devtools/shared/network-observer/NetworkObserver.sys.mjs:740:48
@resource://devtools/shared/network-observer/NetworkObserver.sys.mjs:536:31
makeInfallible/<@resource://devtools/shared/DevToolsInfaillibleUtils.sys.mjs:43:22
inheritAttribute@chrome://global/content/customElements.js:375:18
attributeChangedCallback@chrome://global/content/customElements.js:315:16
setIcon@chrome://browser/content/tabbrowser.js:1010:16
setIconFromLink@resource:///actors/LinkHandlerParent.sys.mjs:161:16
receiveMessage@resource:///actors/LinkHandlerParent.sys.mjs:60:14
Line: 411, column: 11

Interestingly in NetworkObserver.sys.mjs:740 we run the following code for a nsIFileChannel:

fileActivity.owner = this.#onNetworkEvent({}, channel);

But why do we run this code? Why is this a file channel? I cannot actually debug because adding the debugger statement around those lines and having the browser toolbox open crashes Firefox immediately.

Julian could you please check? This blocks at least one Puppeteer test.

Flags: needinfo?(jdescottes)

Maybe a regression from bug 1870580?

Ok, this seems to come from running aTab.setAttribute("iconloadingprincipal", aLoadingPrincipal); which most likely sets the tab icon. That's why we have a file channel.

With a Nightly build that doesn't have the change from bug 1870580 yet, the Puppeteer test still fails. So it's not related.

Flags: needinfo?(jdescottes) → needinfo?(dotoole)
Keywords: regression
Regressed by: 1870580

Valetin, could you team please have a look at this issue. It's massively spamming the log and makes it harder to investigate test failures for jobs using WebDriver BiDi. Thanks!

Flags: needinfo?(valentin.gosu)

It seems pretty clear that this is related with bug 1870580.
I can't figure out from the patch what's wrong, but we should be able to avoid the error by checking if the channel QIs to nsIHttpChannel before calling visitRequestHeaders ?

Flags: needinfo?(valentin.gosu)

I will take a look and see how we should handle those channels in BiDi. File channels don't support the same APIs as HTTP channels, so we might just skip them until we fully support them in Bug 1826210

Flags: needinfo?(dotoole) → needinfo?(jdescottes)
See Also: → 1826210

Set release status flags based on info from the regressing bug 1870580

File channels do not support the same APIs as other channels and make the NetworkEventRecord throw.
Support should be added in Bug 1826210.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ae5e73b7bdee [bidi] Ignore file channels in BiDi network listener r=webdriver-reviewers,Sasha
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
Flags: needinfo?(jdescottes)

Comment on attachment 9382233 [details]
Bug 1880160 - [bidi] Ignore file channels in BiDi network listener

Beta/Release Uplift Approval Request

  • User impact if declined: When listening to network events with WebDriver BiDi, a lot of errors will pollute the stdout.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): We don't really have an automated test to check that the logs are no longer polluted with random errors, but the modified code only impacts WebDriver BiDi clients and is simply ignoring a new type of network channel, which we don't support correctly yet.
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9382233 - Flags: approval-mozilla-beta?

Comment on attachment 9382233 [details]
Bug 1880160 - [bidi] Ignore file channels in BiDi network listener

Approved for 124.0b4

Attachment #9382233 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Severity: -- → S3
Points: --- → 1
Priority: -- → P2
Whiteboard: [webdriver:m10]
Component: Netmonitor → WebDriver BiDi
Product: DevTools → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: