Skip to content

Commit 23734bb

Browse files
authored
Merge pull request #22 from regulaforensics/fix/maximum-call-stack-excess
Add huge logs b64 proper parsing
2 parents 4d12bc2 + 5b3f77c commit 23734bb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/ext/process-response.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,21 @@ export class Response {
4343

4444
public decodedLog(): string | undefined {
4545
const log = this.lowLvlResponse.log
46-
return log ? String.fromCharCode.apply(null, new Uint8Array(converter.decode(log))) : undefined;
46+
if (log) {
47+
const decoded = converter.decode(log)
48+
const uintArray = new Uint8Array(decoded)
49+
const uintArraySize = uintArray.length
50+
const step = 10000
51+
const result = []
52+
// To avoid maximum call stack size excess
53+
for (let i = 0; i < uintArraySize; i + step) {
54+
const chunk = String.fromCharCode.apply(null, uintArray.slice(i, i + step))
55+
result.push(chunk)
56+
}
57+
return result.join('')
58+
} else {
59+
return undefined
60+
}
4761
}
4862
}
4963

0 commit comments

Comments
 (0)