fixed 修复构建速度
This commit is contained in:
1 parent
327cdeb818
commit
d13c6e4d85
2 files changed
+110
-113
No files matched your search
@@ -9,7 +9,7 @@ const MAX_POSTS_PER_FRIEND = 5;
|
||||
const MAX_TOTAL_POSTS = 100; // Limit total output size
|
||||
|
||||
const parser = new Parser({
|
||||
timeout: 10000,
|
||||
timeout: 5000,
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
|
||||
}
|
||||
@@ -21,7 +21,7 @@ async function fetchFeed(url) {
|
||||
return feed;
|
||||
} catch (error) {
|
||||
// console.error(`Failed to fetch ${url}: ${error.message}`);
|
||||
return null;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ async function main() {
|
||||
let allPosts = [];
|
||||
|
||||
// Process friends in batches to avoid overwhelming network
|
||||
const BATCH_SIZE = 5;
|
||||
const BATCH_SIZE = 10;
|
||||
const friends = data.friends;
|
||||
|
||||
for (let i = 0; i < friends.length; i += BATCH_SIZE) {
|
||||
@@ -100,15 +100,12 @@ async function main() {
|
||||
}
|
||||
|
||||
let feed = null;
|
||||
for (const url of candidates) {
|
||||
feed = await fetchFeed(url);
|
||||
if (feed) {
|
||||
// console.log(`[${name}] Fetched RSS: ${url}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!feed) {
|
||||
try {
|
||||
// Try all candidates in parallel and take the first success
|
||||
feed = await Promise.any(candidates.map(url => fetchFeed(url)));
|
||||
// console.log(`[${name}] Fetched RSS successfully.`);
|
||||
} catch (err) {
|
||||
// All candidates failed
|
||||
console.log(`[${name}] No valid RSS found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user