Fix UI lock-up when typed arrays are expanded in debug window

closes #5283
This commit is contained in:
Steve-Mcl
2025-10-05 12:18:18 +01:00
parent 9ad329e5a1
commit 36f98133bf
4 changed files with 201 additions and 7 deletions

View File

@@ -877,14 +877,16 @@ function encodeObject(msg,opts) {
});
} else {
var isArray = Array.isArray(msg.msg);
var needsStringify = isArray;
if (isArray) {
msg.format = "array["+msg.msg.length+"]";
const isTypedArray = ArrayBuffer.isView(msg.msg);
var needsStringify = isArray || isTypedArray;
var typeName = isArray ? 'array' : constructorName(msg.msg);
if (isArray || isTypedArray) {
msg.format = typeName + "["+msg.msg.length+"]";
if (msg.msg.length > debuglength) {
// msg.msg = msg.msg.slice(0,debuglength);
msg.msg = {
__enc__: true,
type: "array",
type: typeName,
data: msg.msg.slice(0,debuglength),
length: msg.msg.length
}
@@ -948,6 +950,16 @@ function encodeObject(msg,opts) {
data: value.slice(0,debuglength),
length: value.length
}
} else if (ArrayBuffer.isView(value) && value.length > debuglength && !Buffer.isBuffer(value)) { // include typed arrays, exclude Buffer
// Note: Buffer is a subclass of Uint8Array
const typeName = constructorName(value);
/** @type {ArrayBufferView} */
value = {
__enc__: true,
type: typeName,
data: Array.from(value).slice(0,debuglength),
length: value.length
}
} else if (typeof value === 'string') {
if (value.length > debuglength) {
value = value.substring(0,debuglength)+"...";
@@ -978,6 +990,13 @@ function encodeObject(msg,opts) {
if (value.length > debuglength) {
value.data = value.data.slice(0,debuglength);
}
} else if (ArrayBuffer.isView(value)) {
value = {
__enc__: true,
type: "array",
data: Array.from(value),
length: value.length
}
} else if (constructorName(value) === "ServerResponse") {
value = "[internal]"
} else if (constructorName(value) === "Socket") {