Open Bug 1448833 Opened 6 years ago Updated 2 years ago

Never send Error.prototype.stack as longString

Categories

(DevTools :: Console, enhancement, P3)

enhancement

Tracking

(firefox61 affected)

Tracking Status
firefox61 --- affected

People

(Reporter: nchevobbe, Unassigned)

Details

We are currently trying to display more helpful Error objects in the console frontend, by parsing Error.stack in order to have a proper, actionable, sourcemapped stacktrace for the user.

In some case, the stack can be quite large and the server sends it as a longString in the initial packet. This is something that gets in our way as we'd need to make a call to the server to get the full stack and print it.

A first, reasonable approach would be to never send it as a long string so the client can parse it as it wants.

A second, more helpful approach would be to send a `stacktrace` property which would look like: 

```js
stacktrace: [{
      "filename": "http://example.com/test-console-api.html",
      "lineNumber": 3,
      "columnNumber": 5,
      "functionName": "bar"
}, {
      "filename": "http://example.com/test-console-api.html",
      "lineNumber": 6,
      "columnNumber": 5,
      "functionName": "foo"
}]
```

This is done in [1] for pageError (the protocol name for exception), but I'm not sure we have the same data since Error.stack is writable and thus can be altered by content scripts. At least we should aim for something similar and fallback on plain string if there's an issue.


[1] https://searchfox.org/mozilla-central/rev/003262ae12ce937950ffb8d3b0fa520d1cc38bff/devtools/server/actors/webconsole.js#1566-1582,1621
We might still want to truncate this so the packet size isn't too large and doesn't freeze the browser
Product: Firefox → DevTools
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.