feedkeeper 0.36.11 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/dist/feeds/extractor.js +1 -1
- package/server/dist/feeds/fullText.js +6 -0
- package/server/dist/feeds/fullTextBackoff.js +46 -0
- package/server/dist/feeds/fullTextQueue.js +14 -6
- package/server/dist/oauth/pages.js +8 -8
- package/server/package.json +1 -1
- package/web/dist/assets/{index-D-4I1D7w.js → index-JhZPH8vz.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/sw.js +1 -1
package/package.json
CHANGED
|
@@ -261,7 +261,7 @@ async function extractArticleContent(rawUrl, fetchImpl, signal) {
|
|
|
261
261
|
if (error instanceof ArticleHttpError && [429, 503].includes(error.status))
|
|
262
262
|
return { status: "throttled", retryAt: error.retryAt, host: error.host };
|
|
263
263
|
if (error instanceof ArticleHttpError && error.status === 403)
|
|
264
|
-
return { status: "bot_blocked" };
|
|
264
|
+
return { status: "bot_blocked", host: error.host };
|
|
265
265
|
return { status: "failed" };
|
|
266
266
|
}
|
|
267
267
|
finally {
|
|
@@ -7,6 +7,8 @@ import { SsrfBlockedError } from "./ssrfGuard.js";
|
|
|
7
7
|
import { improvesContent } from "./articleContent.js";
|
|
8
8
|
import { refreshLead } from "./lead.js";
|
|
9
9
|
import { canAccessItem, findItemById, findSubscriptionFullTextMode, updateItemFullContent } from "./repository.js";
|
|
10
|
+
import { clearFullTextBlocks, recordFullTextBlock } from "./fullTextBackoff.js";
|
|
11
|
+
import { sourceHost } from "./requestGate.js";
|
|
10
12
|
// Kept for integrations importing the old constant; retries now belong to individual articles.
|
|
11
13
|
export const FULL_TEXT_BLOCK_THRESHOLD = 2;
|
|
12
14
|
function recordAttempt(id, status) {
|
|
@@ -64,6 +66,10 @@ export async function executeFullText(userId, itemId, force, priority) {
|
|
|
64
66
|
return { ok: false, error: "capability_not_available" };
|
|
65
67
|
if (result.status === "throttled")
|
|
66
68
|
return { ok: false, error: "source_busy", retryable: true, retryAt: result.retryAt, host: result.host, deferred: result.deferred };
|
|
69
|
+
if (result.status === "bot_blocked")
|
|
70
|
+
recordFullTextBlock(result.host);
|
|
71
|
+
if (result.status === "ok" || result.status === "partial")
|
|
72
|
+
clearFullTextBlocks(sourceHost(item.link));
|
|
67
73
|
if (result.status !== "ok") {
|
|
68
74
|
recordAttempt(itemId, result.status);
|
|
69
75
|
return { ok: false, error: result.status === "failed" ? "could_not_extract_content" : result.status,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { sourceHost } from "./requestGate.js";
|
|
2
|
+
const BLOCK_THRESHOLD = 3;
|
|
3
|
+
const BLOCK_WINDOW_MS = 5 * 60_000;
|
|
4
|
+
const PAUSE_MS = 30 * 60_000;
|
|
5
|
+
const MAX_TRACKED_HOSTS = 1024;
|
|
6
|
+
const hosts = new Map();
|
|
7
|
+
export function recordFullTextBlock(host, now = Date.now()) {
|
|
8
|
+
const previous = hosts.get(host);
|
|
9
|
+
const current = previous && previous.expiresAt > now ? previous : undefined;
|
|
10
|
+
if (current && current.failures >= BLOCK_THRESHOLD)
|
|
11
|
+
return;
|
|
12
|
+
const failures = (current?.failures ?? 0) + 1;
|
|
13
|
+
const expiresAt = failures >= BLOCK_THRESHOLD ? now + PAUSE_MS : current?.expiresAt ?? now + BLOCK_WINDOW_MS;
|
|
14
|
+
hosts.delete(host);
|
|
15
|
+
if (hosts.size >= MAX_TRACKED_HOSTS)
|
|
16
|
+
hosts.delete(hosts.keys().next().value);
|
|
17
|
+
hosts.set(host, { failures, expiresAt });
|
|
18
|
+
}
|
|
19
|
+
export function clearFullTextBlocks(host) {
|
|
20
|
+
hosts.delete(host);
|
|
21
|
+
}
|
|
22
|
+
export function isBackgroundFullTextPaused(host, now = Date.now()) {
|
|
23
|
+
const state = hosts.get(host);
|
|
24
|
+
return !!state && state.expiresAt > now && state.failures >= BLOCK_THRESHOLD;
|
|
25
|
+
}
|
|
26
|
+
export function pruneFullTextBlocks(now = Date.now()) {
|
|
27
|
+
let paused = 0;
|
|
28
|
+
for (const [host, state] of hosts) {
|
|
29
|
+
if (state.expiresAt <= now)
|
|
30
|
+
hosts.delete(host);
|
|
31
|
+
else if (state.failures >= BLOCK_THRESHOLD)
|
|
32
|
+
paused++;
|
|
33
|
+
}
|
|
34
|
+
return paused;
|
|
35
|
+
}
|
|
36
|
+
export function isBackgroundFullTextLinkPaused(link) {
|
|
37
|
+
if (!hosts.size)
|
|
38
|
+
return false;
|
|
39
|
+
try {
|
|
40
|
+
return isBackgroundFullTextPaused(sourceHost(link));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=fullTextBackoff.js.map
|
|
@@ -6,6 +6,8 @@ import { loadFullText, executeFullText } from "./fullText.js";
|
|
|
6
6
|
import { articleWorkPool, restartArticleWorkPool } from "./articleWorkPool.js";
|
|
7
7
|
import { sourceHost } from "./requestGate.js";
|
|
8
8
|
import { canAccessItem, findSubscriptionFullTextMode, findItemById } from "./repository.js";
|
|
9
|
+
import { isBackgroundFullTextLinkPaused, isBackgroundFullTextPaused, pruneFullTextBlocks } from "./fullTextBackoff.js";
|
|
10
|
+
db.function("background_full_text_paused", (link) => Number(isBackgroundFullTextLinkPaused(link)));
|
|
9
11
|
/** Refillable durable queue, bounded independently of library size. */
|
|
10
12
|
export function scheduleFullTexts() {
|
|
11
13
|
const queued = db.prepare("SELECT COUNT(*) n FROM full_text_jobs").get();
|
|
@@ -17,7 +19,7 @@ export function scheduleFullTexts() {
|
|
|
17
19
|
return 0;
|
|
18
20
|
const candidates = db.prepare(`
|
|
19
21
|
WITH candidate_articles AS (
|
|
20
|
-
SELECT ids.value AS item_id, e.user_id, 3 AS priority, i.created_at
|
|
22
|
+
SELECT ids.value AS item_id, e.user_id, 3 AS priority, i.created_at, i.link
|
|
21
23
|
FROM editions e, json_each(e.item_ids) ids
|
|
22
24
|
JOIN items i ON i.id = ids.value
|
|
23
25
|
WHERE e.user_id IN (SELECT value FROM json_each(?))
|
|
@@ -30,7 +32,7 @@ export function scheduleFullTexts() {
|
|
|
30
32
|
|
|
31
33
|
UNION ALL
|
|
32
34
|
|
|
33
|
-
SELECT b.item_id, b.user_id, 2 AS priority, i.created_at
|
|
35
|
+
SELECT b.item_id, b.user_id, 2 AS priority, i.created_at, i.link
|
|
34
36
|
FROM item_bookmarks b
|
|
35
37
|
JOIN items i ON i.id = b.item_id
|
|
36
38
|
WHERE b.user_id IN (SELECT value FROM json_each(?))
|
|
@@ -42,7 +44,7 @@ export function scheduleFullTexts() {
|
|
|
42
44
|
|
|
43
45
|
UNION ALL
|
|
44
46
|
|
|
45
|
-
SELECT n.item_id, n.user_id, 2 AS priority, i.created_at
|
|
47
|
+
SELECT n.item_id, n.user_id, 2 AS priority, i.created_at, i.link
|
|
46
48
|
FROM item_notes n
|
|
47
49
|
JOIN items i ON i.id = n.item_id
|
|
48
50
|
WHERE n.user_id IN (SELECT value FROM json_each(?))
|
|
@@ -54,7 +56,7 @@ export function scheduleFullTexts() {
|
|
|
54
56
|
|
|
55
57
|
UNION ALL
|
|
56
58
|
|
|
57
|
-
SELECT i.id AS item_id, s.user_id, 1 AS priority, i.created_at
|
|
59
|
+
SELECT i.id AS item_id, s.user_id, 1 AS priority, i.created_at, i.link
|
|
58
60
|
FROM subscriptions s
|
|
59
61
|
JOIN items i ON i.feed_id = s.feed_id
|
|
60
62
|
WHERE s.user_id IN (SELECT value FROM json_each(?))
|
|
@@ -66,8 +68,9 @@ export function scheduleFullTexts() {
|
|
|
66
68
|
)
|
|
67
69
|
SELECT item_id AS id, user_id, MAX(priority) AS priority
|
|
68
70
|
FROM candidate_articles
|
|
71
|
+
WHERE ? = 0 OR background_full_text_paused(link) = 0
|
|
69
72
|
GROUP BY item_id
|
|
70
|
-
ORDER BY (priority + CAST((julianday('now')-julianday(created_at))*1440 / 60 AS INTEGER)) DESC, created_at ASC LIMIT ?`).all(JSON.stringify(eligible), JSON.stringify(eligible), JSON.stringify(eligible), JSON.stringify(eligible), room);
|
|
73
|
+
ORDER BY (priority + CAST((julianday('now')-julianday(created_at))*1440 / 60 AS INTEGER)) DESC, created_at ASC LIMIT ?`).all(JSON.stringify(eligible), JSON.stringify(eligible), JSON.stringify(eligible), JSON.stringify(eligible), pruneFullTextBlocks(), room);
|
|
71
74
|
const add = db.prepare("INSERT OR IGNORE INTO full_text_jobs(item_id, user_id, priority, created_at) VALUES (?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ','now'))");
|
|
72
75
|
let count = 0;
|
|
73
76
|
db.transaction(() => {
|
|
@@ -251,6 +254,11 @@ function pump() {
|
|
|
251
254
|
finishListeners(job.item_id, { ok: false, error: "item_has_no_link" });
|
|
252
255
|
continue;
|
|
253
256
|
}
|
|
257
|
+
// Drop planned work so paused sources cannot fill the queue. The planner can select it again after the pause.
|
|
258
|
+
if (job.priority < 4 && isBackgroundFullTextPaused(host)) {
|
|
259
|
+
db.prepare("DELETE FROM full_text_jobs WHERE item_id=?").run(job.item_id);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
254
262
|
const cooldown = db.prepare("SELECT retry_at FROM full_text_hosts WHERE host=?").get(host);
|
|
255
263
|
if (cooldown && Date.parse(cooldown.retry_at) > Date.now()) {
|
|
256
264
|
db.prepare("UPDATE full_text_jobs SET available_at=? WHERE item_id=?").run(cooldown.retry_at, job.item_id);
|
|
@@ -337,7 +345,7 @@ export function startFullTextScheduler() {
|
|
|
337
345
|
db.prepare("DELETE FROM full_text_hosts WHERE julianday(retry_at) <= julianday(?)").run(new Date().toISOString());
|
|
338
346
|
scheduleFullTexts();
|
|
339
347
|
wake();
|
|
340
|
-
console.log(JSON.stringify({ event: "fulltext_queue", ...fullTextMetrics() }));
|
|
348
|
+
console.log(JSON.stringify({ event: "fulltext_queue", ...fullTextMetrics(), pausedHosts: pruneFullTextBlocks() }));
|
|
341
349
|
};
|
|
342
350
|
// Repair old consent-only caches once; the normal bounded planner performs network work.
|
|
343
351
|
const cached = db.prepare("SELECT id,full_content_html FROM items WHERE full_content_html IS NOT NULL AND (lower(full_content_html) LIKE '%cookie%' OR lower(full_content_html) LIKE '%consent%') LIMIT 100").all();
|
|
@@ -50,23 +50,23 @@ const strings = {
|
|
|
50
50
|
forbidden: "Die Anfrage kam von einer anderen Website und wurde blockiert.",
|
|
51
51
|
},
|
|
52
52
|
ja: {
|
|
53
|
-
passkey: "
|
|
54
|
-
loginTitle: "FeedKeeper
|
|
55
|
-
loginIntro: "{client}
|
|
53
|
+
passkey: "パスキーでログイン",
|
|
54
|
+
loginTitle: "FeedKeeperにログイン",
|
|
55
|
+
loginIntro: "{client}がFeedKeeperアカウントへの接続を求めています。続けるにはログインしてください。",
|
|
56
56
|
email: "メールアドレス",
|
|
57
57
|
password: "パスワード",
|
|
58
|
-
signIn: "
|
|
58
|
+
signIn: "ログイン",
|
|
59
59
|
badLogin: "メールアドレスまたはパスワードが正しくありません。",
|
|
60
60
|
consentTitle: "アクセスを許可しますか?",
|
|
61
|
-
consentIntro: "{client}
|
|
62
|
-
returnsTo: "選択後は
|
|
61
|
+
consentIntro: "{client}がMCP経由でFeedKeeperアカウントにアクセスしようとしています。",
|
|
62
|
+
returnsTo: "選択後は{host}に戻ります。",
|
|
63
63
|
readOnly: "読み取りのみ",
|
|
64
64
|
readOnlyHint: "フィードと記事を参照します。変更はしません。",
|
|
65
65
|
readWrite: "読み取りと書き込み",
|
|
66
|
-
readWriteHint: "
|
|
66
|
+
readWriteHint: "記事の既読化や保存、フィードとフォルダーの管理も行えます。",
|
|
67
67
|
allow: "許可",
|
|
68
68
|
deny: "拒否",
|
|
69
|
-
signedInAs: "{user}
|
|
69
|
+
signedInAs: "{user}としてログイン中",
|
|
70
70
|
errorTitle: "このリクエストは完了できません",
|
|
71
71
|
unknownClient: "このアプリはこのサーバーに登録されていません。",
|
|
72
72
|
badRedirect: "戻り先のアドレスがアプリの登録と一致しません。",
|