Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix decoding issue for request data chunks
Nriver30c3c105246a
diff --git a/src/services/request.js b/src/services/request.jsindex 0334c09865..610e44f515 100644--- a/src/services/request.js+++ b/src/services/request.js@@ -63,10 +63,15 @@ function exec(opts) {}let responseStr = '';+ let chunks = [];- response.on('data', chunk => responseStr += chunk);+ response.on('data', chunk => chunks.push(chunk));response.on('end', () => {+ // use Buffer instead of string concatenation to avoid implicit decoding for each chunk+ // decode the entire data chunks explicitly as utf-8+ responseStr = Buffer.concat(chunks).toString('utf-8')+if ([200, 201, 204].includes(response.statusCode)) {try {const jsonObj = responseStr.trim() ? JSON.parse(responseStr) : null;