diff --git a/bin/utils/client.js b/bin/utils/client.js index c845cf9..32ebfe4 100644 --- a/bin/utils/client.js +++ b/bin/utils/client.js @@ -9,7 +9,27 @@ export const isResError = resclient.isResError; class ApiClient extends ResClient { constructor(apiUrl, token) { - super(() => new WebSocket(apiUrl)); + let debugLog = []; + super(() => new WebSocket(apiUrl), { + debug: (type, msg, ctx) => { + // Debug logging for a specific type of error. If encountered, + // we output all stored logs. To prevent large binaries, we + // replace them with a char count. + debugLog.push(Date.now() + " " + msg.replace(/"binary":"([^"]*)"/g, (m, a, b) => `"binary":"CHARS(${a.length})"`)); + if (type == 'addIndirectError') { + console.log("\n--------- LOG DUMP START ----------\n"); + for (let d of debugLog) { + console.log(d); + } + console.log("\n---------- LOG DUMP END -----------\n"); + console.log("You've encountered a tricky to replicate bug!"); + console.log("To help me resolve it, copy the logs above (from LOG DUMP START to LOG DUMP END).\nThen go to GitHub and create an issue with the logs at:\n"); + console.log("https://github.com/mucklet/mucklet-script/issues"); + console.log("\nThanks for the helping me solve this!") + console.log("/Accipiter") + } + }, + }); this.authErr = null; diff --git a/package-lock.json b/package-lock.json index 1aba444..fdd2607 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "assemblyscript": "^0.28.8", "isomorphic-ws": "^5.0.0", "json-as": "1.1.21", - "resclient": "^2.5.0", + "resclient": "^2.5.1", "tinyargs": "^0.1.4", "visitor-as": "^0.11.4" }, @@ -1018,9 +1018,9 @@ } }, "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "dev": true, "dependencies": { "argparse": "^2.0.1" @@ -1409,9 +1409,9 @@ } }, "node_modules/resclient": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/resclient/-/resclient-2.5.0.tgz", - "integrity": "sha512-vG2DMDtVxCfesGNXN41r5+TUpGEKRc2NyE1QHHis9wJP5a0Ci29YSSfIBvD4tPEJeEM9vP0Kn7A4xcrs1KIAFw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/resclient/-/resclient-2.5.1.tgz", + "integrity": "sha512-mGaXRocKEo4ntgJDN+1RcqkYrocJkTl1mz7N+Jajb9qbXIiL85FcRsXKQo1Rb6Yo2JJgsFbGPkYvUuvjL+Wayg==", "dependencies": { "modapp-eventbus": "^1.8.2", "modapp-utils": "^1.8.0" diff --git a/package.json b/package.json index fd1b3f8..f14c205 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "assemblyscript": "^0.28.8", "isomorphic-ws": "^5.0.0", "json-as": "1.1.21", - "resclient": "^2.5.0", + "resclient": "^2.5.1", "tinyargs": "^0.1.4", "visitor-as": "^0.11.4" },