Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc135531

Browse files
fix: prevent stack overflow when logging error occurs
1 parente26d517 commitc135531

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

‎components/esp32-javascript/modules/esp32-javascript/filelogging.js‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,18 @@ function cleanupOldLogs() {
5454
}
5555
}
5656
global.el_flushLogBuffer=function(){
57+
varswap=global.logBuffer;// swap to prevent endless loop when error occurs in this method
58+
global.logBuffer=newstringbuffer_1.StringBuffer();
5759
varlogFile=exports.FILE_LOGGING_DIRECTORY+"/logs-"+getLogFileNumber()+".txt";
58-
varret=appendFile(logFile,global.logBuffer.toString());
59-
if(ret<0){
60-
console.error("Could not flush log file. Space exceeded?");
60+
try{
61+
varret=appendFile(logFile,swap.toString());
62+
if(ret<0){
63+
console.error("Could not flush log file. Space exceeded?");
64+
}
65+
}
66+
catch(error){
67+
console.error("Could not open log file. Space exceeded?");
6168
}
62-
global.logBuffer=newstringbuffer_1.StringBuffer();
6369
if(fileSize(logFile)>exports.LOG_FILE_SIZE_LIMIT){
6470
logFileNumber++;
6571
}

‎components/esp32-javascript/modules/esp32-javascript/filelogging.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@ function cleanupOldLogs() {
5757
}
5858

5959
global.el_flushLogBuffer=function():void{
60+
constswap=global.logBuffer;// swap to prevent endless loop when error occurs in this method
61+
global.logBuffer=newStringBuffer();
62+
6063
constlogFile=`${FILE_LOGGING_DIRECTORY}/logs-${getLogFileNumber()}.txt`;
61-
constret=appendFile(logFile,global.logBuffer.toString());
62-
if(ret<0){
63-
console.error("Could not flush log file. Space exceeded?");
64+
try{
65+
constret=appendFile(logFile,swap.toString());
66+
if(ret<0){
67+
console.error("Could not flush log file. Space exceeded?");
68+
}
69+
}catch(error){
70+
console.error("Could not open log file. Space exceeded?");
6471
}
6572

66-
global.logBuffer=newStringBuffer();
6773
if(fileSize(logFile)>LOG_FILE_SIZE_LIMIT){
6874
logFileNumber++;
6975
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp