iOS Surge 4.2.0 Build 1574 日志中出现如下Warning
<WARNING> [SGLogger] WARNING: Object didn't release: 0x104cb96a0: <JSContext: 0x104cb96a0>
日志并未将context和脚本联系起来,日志时间戳显示可能是如下的一个每分钟运行一次的cron脚本的问题:
请教如何改进代码才能消除Warning。
$httpClient.get({
url: SOMEURL,
headers: SOMEHEADER
}, (error, response, data) => {
if (error == null) {
res = JSON.parse(data);
var firstNewsTimestamp = $persistentStore.read("firstNewsTimeStamp");
if (isNaN(firstNewsTimestamp)) {
firstNewsTimestamp = '0';
}
let storageTime = Date.parse(res.list[0].time.replace(' ', 'T')).toString(); // max time
if (storageTime != firstNewsTimestamp) {
$persistentStore.write(storageTime, "firstNewsTimeStamp");
}`
list = res.list.reverse()
list = list.filter(item => Date.parse(item.time.replace(' ', 'T')) > parseInt(firstNewsTimestamp)); // more than last round max time
list.map(item => {
let level = parseInt(item.Level);
let type = parseInt(item.Type);
let content = item.content.split('】'); //split title and body
let time = item.time.substr(11, 5); // time substring extract minute and seconds
let title = '';
let body = '';
if (content.length < 2) { // no title
title = '';
if (level == 0) { // i.e. important
body = '★'.repeat(2) + content[0];
}
else {
body = content[0];
}
}
else { // with title
body = content[1];
if (level == 0) { // i.e. important
title = '★'.repeat(2) + content[0].substr(1);
}
else {
title = content[0].substr(1);
}
if (title.length > 23) {
body = '【' + title + '】' + body;
title = '';
}
}
// console.log(level, type, time, title, body)
$notification.post(title, "", body);
});
} else {
console.log("request error for m.fbecn.com");
console.log(error);
console.log(response);
}
});
$done();