Closed Bug 1673897 Opened 4 years ago Closed 3 years ago

Remote debugging fails on requests returning arrays

Categories

(DevTools :: Framework, defect, P3)

defect

Tracking

(firefox85 fixed)

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: ochameau, Assigned: jdescottes)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files, 1 obsolete file)

The only visible breakage I've been able to reproduce is the blocked request sidebar in the netmonitor.

It triggers the WebConsoleActor.getBlockedUrls() request, which is specified this way:
https://searchfox.org/mozilla-central/source/devtools/shared/specs/webconsole.js#249-252

    getBlockedUrls: {
      request: {},
      response: RetVal("array:string"),
    },

Nothing special on the actor, it just returns an array.

We do go through this code in protocol.js's Actor:
https://searchfox.org/mozilla-central/source/devtools/shared/protocol/Actor.js#194,205

  response.from = this.actorID;
  ...
  conn.send(response);

The different which explains why it works within firefox, but not with remote debugging is in the transport layer:

  send: function(packet) {
    ...
    this._deepFreeze(packet);
    ...
    other.hooks.onPacket(packet);

deepFreeze freeze the object, but doesn't do a JSON serialization.

  send: function(object) {
    const packet = new JSONPacket(this);
    packet.object = object;

which uses JSONPacket, doing a JSON serialization:
https://searchfox.org/mozilla-central/source/devtools/shared/transport/packets.js#152

 set: function(object) {
    this._object = object;
    const data = JSON.stringify(object);

And this is where we loose the overloaded from attribute.

This sounds tricky to fix without changing the spec to move the RetVal("array:string") into a sub attribute in the response packet. So that we stop messing with the protocol base JSON object.

We could also fix this in the transport layer. Maybe we should force all requests to wrap their response in an object?

Fixes the request blocking UI in remote debugging.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

The severity field is not set for this bug.
:ochameau, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(poirot.alex)
Severity: -- → S3
Flags: needinfo?(poirot.alex)
Priority: -- → P3
Attachment #9187162 - Attachment is obsolete: true
Blocks: 1677703
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a423cb25ee61
[devtools] Stop using arrays as return values for rdp responses r=ochameau,devtools-backward-compat-reviewers
https://hg.mozilla.org/integration/autoland/rev/acd7500696d6
[devtools] Throw if a spec method defines an array return value r=ochameau
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: