mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 23:34:38 +01:00
Fix UI lock-up when typed arrays are expanded in debug window
closes #5283
This commit is contained in:
27
packages/node_modules/@node-red/util/lib/util.js
vendored
27
packages/node_modules/@node-red/util/lib/util.js
vendored
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user