Skip to content

Commit ebfccde

Browse files
author
Guillaume Chau
committed
fix(perf): limit string size, closes #652, closes #842
1 parent 7345d7a commit ebfccde

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

shells/dev/target/NativeTypes.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ const handler = {
6262
6363
const proxy1 = new Proxy(sum, handler)
6464
65+
let veryLongText = ''
66+
for (let i = 0; i < 1000000; i++) {
67+
veryLongText += `line${i}\n`
68+
}
69+
6570
export default {
6671
components: {
6772
TestComponent: {
@@ -102,7 +107,8 @@ export default {
102107
sym: Symbol('test'),
103108
multiLineParameterFunction: function(a,
104109
b,
105-
c) {}
110+
c) {},
111+
veryLongText
106112
}
107113
},
108114
computed: {

src/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export const SPECIAL_TOKENS = {
5959
'NaN': NAN
6060
}
6161

62+
export const MAX_STRING_SIZE = 10000
63+
6264
export function specialTokenToString (value) {
6365
if (value === null) {
6466
return 'null'
@@ -149,6 +151,8 @@ function replacer (key) {
149151
}
150152
} else if (Number.isNaN(val)) {
151153
return NAN
154+
} else if (typeof val === 'string' && val.length > MAX_STRING_SIZE) {
155+
return val.substr(0, MAX_STRING_SIZE) + `... (${(val.length)} total length)`
152156
}
153157
return sanitize(val)
154158
}

0 commit comments

Comments
 (0)