mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1844133 - [remote] WebSocketConnection logs should be truncated for huge objects r=webdriver-reviewers,Sasha
Puppeteer happens to send huge payloads as part of their test suite when using their $$eval API. This is because they pass back and forth nodeLists for which all children are serialized by default. This could be avoided by changing the serialization options (see https://github.com/puppeteer/puppeteer/issues/10582) But without such a fix, we need to cap the size of the websocket logs, otherwise the logparser is unable to handle the logs from the bidi puppeteer job. Differential Revision: https://phabricator.services.mozilla.com/D184108
This commit is contained in:
parent
0cad8e2125
commit
525aa4d10f
@ -17,6 +17,8 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
|
||||
XPCOMUtils.defineLazyGetter(lazy, "logger", () => lazy.Log.get());
|
||||
|
||||
const MAX_LOG_LENGTH = 2500;
|
||||
|
||||
export class WebSocketConnection {
|
||||
/**
|
||||
* @param {WebSocket} webSocket
|
||||
@ -45,12 +47,20 @@ export class WebSocketConnection {
|
||||
return value;
|
||||
}
|
||||
|
||||
const payload = JSON.stringify(
|
||||
let payload = JSON.stringify(
|
||||
data,
|
||||
replacer,
|
||||
lazy.Log.verbose ? "\t" : null
|
||||
);
|
||||
|
||||
if (payload.length > MAX_LOG_LENGTH) {
|
||||
// Even if we truncate individual values, the resulting message might be
|
||||
// huge if we are serializing big objects with many properties or items.
|
||||
// Truncate the overall message to avoid issues in logs.
|
||||
const truncated = payload.substring(0, MAX_LOG_LENGTH);
|
||||
payload = `${truncated} [... truncated after ${MAX_LOG_LENGTH} characters]`;
|
||||
}
|
||||
|
||||
lazy.logger.debug(
|
||||
`${this.constructor.name} ${this.id} ${direction} ${payload}`
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user