feedkeeper 0.44.1 → 0.44.3

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.
@@ -64,3 +64,34 @@ If the Work includes a "NOTICE" text file as part of its distribution, then any
64
64
 
65
65
  END OF TERMS AND CONDITIONS
66
66
  ```
67
+
68
+ ## oEmbed Providers
69
+
70
+ - **Source:** [iamcal/oembed](https://github.com/iamcal/oembed) (`https://oembed.com/providers.json`)
71
+ - **Copyright:** Copyright (c) 2016 Cal Henderson
72
+ - **License:** MIT License
73
+ - **Used in:** [`server/src/feeds/content/patterns/providers.json`](server/src/feeds/content/patterns/providers.json)
74
+
75
+ ```text
76
+ The MIT License (MIT)
77
+
78
+ Copyright (c) 2016 Cal Henderson
79
+
80
+ Permission is hereby granted, free of charge, to any person obtaining a copy
81
+ of this software and associated documentation files (the "Software"), to deal
82
+ in the Software without restriction, including without limitation the rights
83
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
84
+ copies of the Software, and to permit persons to whom the Software is
85
+ furnished to do so, subject to the following conditions:
86
+
87
+ The above copyright notice and this permission notice shall be included in all
88
+ copies or substantial portions of the Software.
89
+
90
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
91
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
92
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
93
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
94
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
95
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
96
+ SOFTWARE.
97
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feedkeeper",
3
- "version": "0.44.1",
3
+ "version": "0.44.3",
4
4
  "description": "A lightweight, self-hosted RSS reader and remote MCP server for your news, blogs, and AI workflows.",
5
5
  "keywords": [
6
6
  "rss",
@@ -5,12 +5,14 @@ export function socialPost(source) {
5
5
  const address = parseAddress(source.trim());
6
6
  if (!address || !/^https?:$/.test(address.protocol))
7
7
  return null;
8
- const host = address.hostname.replace(/^(?:www|m|mobile)\./, "");
9
- const platform = SOCIAL_PLATFORMS.find(candidate => candidate.host.test(host));
10
- if (!platform || !platform.post.test(`${address.pathname}${address.search}`))
8
+ const platform = SOCIAL_PLATFORMS.find(candidate => candidate.host.test(address.hostname) && candidate.post.test(address.href));
9
+ if (!platform)
11
10
  return null;
12
- const keepsQuery = platform.name === "Facebook";
13
- return { platform, url: `${address.origin}${address.pathname.replace(/\/embed\/?$/, "/")}${keepsQuery ? address.search : ""}` };
11
+ const keepsQuery = platform.name === "Facebook" || platform.name === "YouTube";
12
+ return {
13
+ platform,
14
+ url: `${address.origin}${address.pathname.replace(/\/embed\/?$/, "/")}${keepsQuery ? address.search : ""}`,
15
+ };
14
16
  }
15
17
  /** The post behind an embed iframe, which usually names it in the path or in a parameter. */
16
18
  export function socialFrameTarget(source) {
@@ -36,7 +38,10 @@ export function socialFrameTarget(source) {
36
38
  return inner ? socialPost(inner) : null;
37
39
  }
38
40
  if (MASTODON_EMBED_PATH.test(address.pathname) && /^https?:$/.test(address.protocol)) {
39
- return { platform: { name: "Mastodon", host: /.*/, post: MASTODON_EMBED_PATH, kind: "social" }, url: `${address.origin}${address.pathname.replace(/\/embed\/?$/, "")}` };
41
+ return {
42
+ platform: { name: "Mastodon", host: /.*/, post: MASTODON_EMBED_PATH, kind: "social" },
43
+ url: `${address.origin}${address.pathname.replace(/\/embed\/?$/, "")}`,
44
+ };
40
45
  }
41
46
  return socialPost(source);
42
47
  }
@@ -90,7 +95,7 @@ function resolveSocialEmbeds(root, stats) {
90
95
  /** Posts of social platforms and audio players become one link to the post. */
91
96
  export const socialEmbeds = {
92
97
  name: "social-embeds",
93
- description: "Instagram, X, TikTok, Bluesky, Threads, Reddit, Facebook posts and Spotify/SoundCloud players become one marked link.",
98
+ description: "Supported social posts and audio players become one marked link.",
94
99
  apply(root, stats) {
95
100
  const { changed, links } = resolveSocialEmbeds(root, stats);
96
101
  links.forEach(({ link, kind, source }) => {
@@ -1,4 +1,5 @@
1
1
  import { PLAY_LABEL, PLAYER_TITLES } from "../patterns/play-labels/index.js";
2
+ import { OEMBED_PROVIDER_PLATFORMS } from "../patterns/oembed-providers.js";
2
3
  import { flat, linkParagraph, parseAddress, pruneEmpty } from "../shared.js";
3
4
  const PLAY_SOURCE = /(?:^|[/_.-])play[-_]?(?:icon|button|btn)?\.(?:svg|png|webp|gif)(?:[?#]|$)/i;
4
5
  const DURATION = /^\d{1,2}:\d{2}(:\d{2})?$/;
@@ -8,39 +9,44 @@ function isPlayOverlay(image) {
8
9
  }
9
10
  /** Direct video URL of the embeds that are common enough to be worth a link. Anything else is not turned into a link. */
10
11
  export function embedTarget(source) {
11
- const parsed = parseAddress(source);
12
- if (!parsed)
12
+ const trimmed = source.trim();
13
+ const address = parseAddress(trimmed.startsWith("//") ? `https:${trimmed}` : trimmed);
14
+ if (!address || !/^https?:$/.test(address.protocol))
13
15
  return null;
14
- const address = parsed;
15
- const host = address.hostname.replace(/^www\./, "");
16
- const segments = address.pathname.split("/").filter(Boolean);
17
- if (/^youtube(-nocookie)?\.com$/.test(host) && segments[0] === "embed" && /^[\w-]{6,}$/.test(segments[1] ?? "")) {
18
- return { url: `https://www.youtube.com/watch?v=${segments[1]}`, name: "YouTube" };
19
- }
20
- if (/^(?:m\.)?youtube\.com$/.test(host) && segments[0] === "watch" && /^[\w-]{6,}$/.test(address.searchParams.get("v") ?? "")) {
21
- return { url: `https://www.youtube.com/watch?v=${address.searchParams.get("v")}`, name: "YouTube" };
16
+ const host = address.hostname.replace(/^(?:www|m|mobile)\./, "");
17
+ const provider = OEMBED_PROVIDER_PLATFORMS.find(candidate => candidate.kind === "video" && candidate.post.test(address.href));
18
+ if (provider?.name === "YouTube") {
19
+ const id = address.searchParams.get("v") ?? address.pathname.split("/").filter(Boolean).at(-1);
20
+ if (id && /^[\w-]{6,}$/.test(id)) {
21
+ return { url: `https://www.youtube.com/watch?v=${id}`, name: provider.name };
22
+ }
22
23
  }
23
- if (host === "youtu.be" && /^[\w-]{6,}$/.test(segments[0] ?? "")) {
24
- return { url: `https://www.youtube.com/watch?v=${segments[0]}`, name: "YouTube" };
24
+ if (provider?.name === "Vimeo" && host === "player.vimeo.com") {
25
+ const id = address.pathname.match(/\/video\/(\d{5,})$/)?.[1];
26
+ if (id) {
27
+ return { url: `https://vimeo.com/${id}`, name: provider.name };
28
+ }
25
29
  }
26
- if (host === "player.vimeo.com" && segments[0] === "video" && /^\d+$/.test(segments[1] ?? "")) {
27
- return { url: `https://vimeo.com/${segments[1]}`, name: "Vimeo" };
30
+ if (provider?.name === "Dailymotion") {
31
+ const id = address.pathname.match(/^\/video\/([a-zA-Z0-9]+)/)?.[1];
32
+ if (id) {
33
+ return { url: `https://www.dailymotion.com/video/${id}`, name: provider.name };
34
+ }
28
35
  }
29
- if (host === "dailymotion.com" && segments[0] === "embed" && segments[1] === "video" && /^\w+$/.test(segments[2] ?? "")) {
30
- return { url: `https://www.dailymotion.com/video/${segments[2]}`, name: "Dailymotion" };
36
+ if (host === "dailymotion.com") {
37
+ const id = address.pathname.match(/^\/embed\/video\/([\w]+)/)?.[1];
38
+ if (id) {
39
+ return { url: `https://www.dailymotion.com/video/${id}`, name: "Dailymotion" };
40
+ }
31
41
  }
32
42
  return null;
33
43
  }
34
44
  /** The name of the video site a watch-page address belongs to, for the labels of links that were saved without a title. */
35
45
  function videoSiteName(source) {
36
- const host = parseAddress(source)?.hostname.replace(/^(?:www|m)\./, "") ?? "";
37
- if (/^(?:youtube(?:-nocookie)?\.com|youtu\.be)$/.test(host))
38
- return "YouTube";
39
- if (/^(?:player\.)?vimeo\.com$/.test(host))
40
- return "Vimeo";
41
- if (/^dailymotion\.com$/.test(host))
42
- return "Dailymotion";
43
- return null;
46
+ const address = parseAddress(source);
47
+ if (!address)
48
+ return null;
49
+ return OEMBED_PROVIDER_PLATFORMS.find(platform => platform.kind === "video" && platform.post.test(address.href))?.name ?? null;
44
50
  }
45
51
  /**
46
52
  * Players need the publisher's script: a reader without it shows their play-button picture as a broken image and
@@ -0,0 +1,69 @@
1
+ import registry from "./providers.json" with { type: "json" };
2
+ export const OEMBED_PROVIDER_SNAPSHOT = registry.snapshot_date;
3
+ const VIDEO_PROVIDERS = new Set(["YouTube", "Vimeo", "Dailymotion"]);
4
+ const AUDIO_PROVIDERS = new Set(["SoundCloud", "Spotify"]);
5
+ function escapeRegex(value) {
6
+ return value.replace(/[.*+?^$()|[\]\\]/g, "\\$&");
7
+ }
8
+ function compileHost(rawHost) {
9
+ if (rawHost === "*.youtube.com") {
10
+ return `(?:[^.]+\\.)?youtube(?:-nocookie)?\\.com`;
11
+ }
12
+ if (rawHost.startsWith("*.")) {
13
+ return `(?:[^.]+\\.)?${escapeRegex(rawHost.slice(2)).replace(/\\\*/g, "[^.]+")}`;
14
+ }
15
+ const bare = rawHost.replace(/^www\./, "");
16
+ if (!bare.includes("*.") && bare.split(".").length === 2) {
17
+ return `(?:(?:www|m|mobile)\\.)?${escapeRegex(bare)}`;
18
+ }
19
+ return escapeRegex(rawHost).replace(/\\\*/g, "[^.]+");
20
+ }
21
+ function compileScheme(scheme) {
22
+ const match = /^(https?):\/\/([^/]+)(\/.*)$/.exec(scheme);
23
+ if (!match) {
24
+ throw new Error(`Invalid oEmbed scheme: ${scheme}`);
25
+ }
26
+ const host = compileHost(match[2]);
27
+ const path = escapeRegex(match[3]).replace(/\\\*/g, "[^#]*");
28
+ return new RegExp(`^${match[1]}://${host}${path}$`, "i");
29
+ }
30
+ /**
31
+ * Single-item URL matchers derived from the versioned oEmbed provider registry snapshot.
32
+ * Run `npm run update:oembed-providers` to refresh `providers.json`.
33
+ */
34
+ export const OEMBED_PROVIDER_PLATFORMS = registry.providers.map(provider => {
35
+ const name = provider.provider_name === "Bluesky Social" ? "Bluesky" : provider.provider_name;
36
+ const schemes = provider.schemes.map(compileScheme);
37
+ const paths = provider.item_paths.map(pattern => new RegExp(pattern, "i"));
38
+ const hosts = provider.schemes.map(scheme => {
39
+ const match = /^(https?):\/\/([^/]+)/.exec(scheme);
40
+ if (!match) {
41
+ throw new Error(`Invalid oEmbed scheme: ${scheme}`);
42
+ }
43
+ return compileHost(match[2]);
44
+ });
45
+ const host = new RegExp(`^(?:${[...new Set(hosts)].join("|")})$`, "i");
46
+ const post = {
47
+ test(value) {
48
+ try {
49
+ const url = new URL(value);
50
+ if (!host.test(url.hostname) ||
51
+ !schemes.some(pattern => pattern.test(url.href)) ||
52
+ !paths.some(pattern => pattern.test(url.pathname))) {
53
+ return false;
54
+ }
55
+ if (name === "YouTube" && url.pathname === "/watch" && !url.searchParams.has("v"))
56
+ return false;
57
+ if (name === "YouTube" && url.pathname === "/playlist" && !url.searchParams.has("list"))
58
+ return false;
59
+ return true;
60
+ }
61
+ catch {
62
+ return false;
63
+ }
64
+ },
65
+ };
66
+ const kind = VIDEO_PROVIDERS.has(name) ? "video" : AUDIO_PROVIDERS.has(name) ? "audio" : "social";
67
+ return { name, host, post, kind };
68
+ });
69
+ //# sourceMappingURL=oembed-providers.js.map
@@ -0,0 +1,152 @@
1
+ {
2
+ "source": "https://oembed.com/providers.json",
3
+ "snapshot_date": "2026-11-23",
4
+ "providers": [
5
+ {
6
+ "provider_name": "Bluesky Social",
7
+ "schemes": [
8
+ "https://bsky.app/profile/*/post/*"
9
+ ],
10
+ "item_paths": [
11
+ "^/profile/[^/]+/post/[^/]+/?$"
12
+ ]
13
+ },
14
+ {
15
+ "provider_name": "Dailymotion",
16
+ "schemes": [
17
+ "https://www.dailymotion.com/video/*",
18
+ "https://geo.dailymotion.com/player.html?video=*"
19
+ ],
20
+ "item_paths": [
21
+ "^/video/[A-Za-z0-9]+/?$"
22
+ ]
23
+ },
24
+ {
25
+ "provider_name": "Flickr",
26
+ "schemes": [
27
+ "https://*.flickr.com/photos/*",
28
+ "https://flic.kr/p/*",
29
+ "https://flic.kr/s/*",
30
+ "https://*.*.flickr.com/*/*"
31
+ ],
32
+ "item_paths": [
33
+ "^/photos/[^/]+/\\d+/?$",
34
+ "^/p/[^/]+/?$"
35
+ ]
36
+ },
37
+ {
38
+ "provider_name": "Instagram",
39
+ "schemes": [
40
+ "https://instagram.com/*/p/*",
41
+ "https://www.instagram.com/*/p/*",
42
+ "https://instagram.com/p/*",
43
+ "https://instagr.am/p/*",
44
+ "https://www.instagram.com/p/*",
45
+ "https://www.instagr.am/p/*",
46
+ "https://instagram.com/tv/*",
47
+ "https://instagr.am/tv/*",
48
+ "https://www.instagram.com/tv/*",
49
+ "https://www.instagr.am/tv/*",
50
+ "https://www.instagram.com/reel/*",
51
+ "https://instagram.com/reel/*",
52
+ "https://instagr.am/reel/*",
53
+ "https://www.instagram.com/*/reel/*",
54
+ "https://instagram.com/*/reel/*"
55
+ ],
56
+ "item_paths": [
57
+ "^/(?:[\\w.]+/)?(?:p|tv|reel|reels)/[\\w-]+/?$"
58
+ ]
59
+ },
60
+ {
61
+ "provider_name": "Reddit",
62
+ "schemes": [
63
+ "https://reddit.com/r/*/comments/*/*",
64
+ "https://www.reddit.com/r/*/comments/*/*"
65
+ ],
66
+ "item_paths": [
67
+ "^/r/[^/]+/comments/[^/]+"
68
+ ]
69
+ },
70
+ {
71
+ "provider_name": "SoundCloud",
72
+ "schemes": [
73
+ "https://soundcloud.com/*",
74
+ "https://on.soundcloud.com/*",
75
+ "https://soundcloud.app.goog.gl/*"
76
+ ],
77
+ "item_paths": [
78
+ "^/[^/]+/[^/]+/?$"
79
+ ]
80
+ },
81
+ {
82
+ "provider_name": "Spotify",
83
+ "schemes": [
84
+ "https://open.spotify.com/*",
85
+ "https://spotify.link/*"
86
+ ],
87
+ "item_paths": [
88
+ "^/(?:track|album|playlist|episode|show|artist)/[A-Za-z0-9]+/?$"
89
+ ]
90
+ },
91
+ {
92
+ "provider_name": "TikTok",
93
+ "schemes": [
94
+ "https://www.tiktok.com/*",
95
+ "https://www.tiktok.com/*/video/*"
96
+ ],
97
+ "item_paths": [
98
+ "^/@[^/]+/(?:video|photo)/\\d+/?$",
99
+ "^/(?:video|photo)/\\d+/?$"
100
+ ]
101
+ },
102
+ {
103
+ "provider_name": "Vimeo",
104
+ "schemes": [
105
+ "https://vimeo.com/*",
106
+ "https://vimeo.com/album/*/video/*",
107
+ "https://vimeo.com/channels/*/*",
108
+ "https://vimeo.com/groups/*/videos/*",
109
+ "https://vimeo.com/ondemand/*/*",
110
+ "https://player.vimeo.com/video/*",
111
+ "https://vimeo.com/event/*/*"
112
+ ],
113
+ "item_paths": [
114
+ "^/\\d{5,}/?$",
115
+ "^/channels/[^/]+/\\d{5,}/?$",
116
+ "^/video/\\d{5,}/?$"
117
+ ]
118
+ },
119
+ {
120
+ "provider_name": "X",
121
+ "schemes": [
122
+ "https://x.com/*",
123
+ "https://x.com/*/status/*",
124
+ "https://*.x.com/*/status/*"
125
+ ],
126
+ "item_paths": [
127
+ "^/(?:i/|[^/]+/)(?:web/)?status/\\d+/?$"
128
+ ]
129
+ },
130
+ {
131
+ "provider_name": "YouTube",
132
+ "schemes": [
133
+ "https://*.youtube.com/watch*",
134
+ "https://*.youtube.com/v/*",
135
+ "https://youtu.be/*",
136
+ "https://*.youtube.com/playlist?list=*",
137
+ "https://youtube.com/playlist?list=*",
138
+ "https://*.youtube.com/shorts*",
139
+ "https://youtube.com/shorts*",
140
+ "https://*.youtube.com/embed/*",
141
+ "https://*.youtube.com/live*",
142
+ "https://youtube.com/live*"
143
+ ],
144
+ "item_paths": [
145
+ "^/watch$",
146
+ "^/playlist$",
147
+ "^/(?:shorts|live|embed|v)/[\\w-]{6,}/?$",
148
+ "^/[\\w-]{6,}/?$"
149
+ ]
150
+ }
151
+ ]
152
+ }
@@ -1,13 +1,39 @@
1
+ import { OEMBED_PROVIDER_PLATFORMS } from "./oembed-providers.js";
2
+ /**
3
+ * Platforms without suitable single-post schemes in the oEmbed provider registry.
4
+ * Mastodon is handled separately because every instance has its own hostname.
5
+ */
6
+ const CUSTOM_SOCIAL_PLATFORMS = [
7
+ {
8
+ name: "Threads",
9
+ host: /^(?:(?:www|m|mobile)\.)?threads\.(?:net|com)$/i,
10
+ post: /^https?:\/\/(?:(?:www|m|mobile)\.)?threads\.(?:net|com)\/@[\w.]+\/post\/[\w-]+(?:[/?#]|$)/i,
11
+ kind: "social",
12
+ },
13
+ {
14
+ name: "Facebook",
15
+ host: /^(?:(?:www|m|mobile)\.)?facebook\.com$/i,
16
+ post: {
17
+ test: value => /^https?:\/\/(?:(?:www|m|mobile)\.)?facebook\.com\/(?:[^/?#]+\/)?(?:posts|activity|photos|videos|permalink|watch|reel|share)\b/i.test(value) ||
18
+ /^https?:\/\/(?:(?:www|m|mobile)\.)?facebook\.com\/(?:photo|permalink|story)\.php\?(?:[^#]*&)?(?:fbid|story_fbid|v)=/i.test(value) ||
19
+ /^https?:\/\/(?:(?:www|m|mobile)\.)?facebook\.com\/[^#]*[?&](?:story_fbid|v)=/i.test(value),
20
+ },
21
+ kind: "social",
22
+ },
23
+ {
24
+ name: "X",
25
+ host: /^(?:(?:www|m|mobile)\.)?twitter\.com$/i,
26
+ post: /^https?:\/\/(?:(?:www|m|mobile)\.)?twitter\.com\/(?:i\/|[\w]+\/)(?:web\/)?status\/\d+/i,
27
+ kind: "social",
28
+ },
29
+ ];
30
+ /**
31
+ * The platforms whose posts become a marked link (`data-media` + `data-source`).
32
+ * A fixture in `test/fixtures/content/social-embeds` shows the expected result.
33
+ */
1
34
  export const SOCIAL_PLATFORMS = [
2
- { name: "Instagram", host: /^instagram\.com$/, post: /^\/(?:[\w.]+\/)?(?:p|reel|reels|tv)\/[\w-]+/, kind: "social" },
3
- { name: "X", host: /^(?:twitter|x)\.com$/, post: /^\/(?:i\/|[\w]+\/)(?:web\/)?status\/\d+/, kind: "social" },
4
- { name: "TikTok", host: /^tiktok\.com$/, post: /\/(?:video|photo)\/\d+/, kind: "social" },
5
- { name: "Bluesky", host: /^bsky\.app$/, post: /^\/profile\/[^/]+\/post\/[\w]+/, kind: "social" },
6
- { name: "Threads", host: /^threads\.(?:net|com)$/, post: /^\/@[\w.]+\/post\/[\w-]+/, kind: "social" },
7
- { name: "Reddit", host: /^reddit\.com$/, post: /^\/r\/\w+\/comments\//, kind: "social" },
8
- { name: "Facebook", host: /^facebook\.com$/, post: /\/(?:posts|videos|photos|permalink|watch|reel|share)\b|[?&](?:story_fbid|v)=/, kind: "social" },
9
- { name: "Spotify", host: /^open\.spotify\.com$/, post: /^\/(?:track|album|playlist|episode|show|artist)\/\w+/, kind: "audio" },
10
- { name: "SoundCloud", host: /^soundcloud\.com$/, post: /^\/[^/]+\/[^/]+/, kind: "audio" },
35
+ ...OEMBED_PROVIDER_PLATFORMS,
36
+ ...CUSTOM_SOCIAL_PLATFORMS,
11
37
  ];
12
38
  /** Classes of the blockquote placeholders that the platforms' scripts turn into the real post. */
13
39
  export const SOCIAL_QUOTE = "blockquote.instagram-media, blockquote.twitter-tweet, blockquote.tiktok-embed, blockquote.bluesky-embed, " +
@@ -1,5 +1,6 @@
1
1
  import { Worker } from "node:worker_threads";
2
2
  const PARSE_TIMEOUT_MS = 15_000;
3
+ const WORKER_MAX_OLD_SPACE_MB = 256;
3
4
  function readWorkerCount() {
4
5
  const raw = process.env.EXTRACTOR_WORKERS;
5
6
  if (raw === undefined)
@@ -9,10 +10,22 @@ function readWorkerCount() {
9
10
  return 2;
10
11
  return parsed;
11
12
  }
13
+ function readMaxTasksPerWorker() {
14
+ const raw = process.env.EXTRACTOR_WORKER_MAX_TASKS;
15
+ if (raw === undefined)
16
+ return 250;
17
+ const parsed = Number(raw);
18
+ if (!Number.isSafeInteger(parsed) || parsed < 1 || parsed > 10_000)
19
+ return 250;
20
+ return parsed;
21
+ }
12
22
  function createWorker() {
13
23
  const isTs = import.meta.url.endsWith(".ts");
14
24
  const url = new URL(isTs ? "./extractorWorker.ts" : "./extractorWorker.js", import.meta.url);
15
- const worker = isTs ? new Worker(url, { execArgv: ["--import", "tsx"] }) : new Worker(url);
25
+ const resourceLimits = { maxOldGenerationSizeMb: WORKER_MAX_OLD_SPACE_MB };
26
+ const worker = isTs
27
+ ? new Worker(url, { execArgv: ["--import", "tsx"], resourceLimits })
28
+ : new Worker(url, { resourceLimits });
16
29
  worker.unref();
17
30
  return worker;
18
31
  }
@@ -32,12 +45,17 @@ class ExtractorWorkerPool {
32
45
  }
33
46
  spawnSlot() {
34
47
  const worker = createWorker();
35
- const slot = { worker, busy: false, current: null, timer: null };
48
+ const slot = { worker, busy: false, current: null, timer: null, tasksProcessed: 0 };
36
49
  worker.on("message", (msg) => {
37
50
  const task = slot.current;
38
51
  if (!task || task.id !== msg.id)
39
52
  return;
40
53
  this.finishSlot(slot);
54
+ slot.tasksProcessed++;
55
+ // Recycle workers periodically so long-lived JSDOM heaps return memory to the OS.
56
+ if (slot.tasksProcessed >= readMaxTasksPerWorker()) {
57
+ this.dropSlot(slot);
58
+ }
41
59
  if (msg.error)
42
60
  task.reject(new Error(msg.error));
43
61
  else if (msg.result)
@@ -12,9 +12,9 @@ import { sourceHost } from "./requestGate.js";
12
12
  // Kept for integrations importing the old constant; retries now belong to individual articles.
13
13
  export const FULL_TEXT_BLOCK_THRESHOLD = 2;
14
14
  function recordAttempt(id, status) {
15
- const blocked = ["paywall", "consent_wall"].includes(status);
15
+ const longPause = ["paywall", "consent_wall", "failed", "bot_blocked", "timeout"].includes(status);
16
16
  const retry = status === "ready" || status === "feed_only" ? null :
17
- new Date(Date.now() + (blocked ? 7 * 86400_000 : status === "partial" ? 86400_000 : 3600_000)).toISOString();
17
+ new Date(Date.now() + (longPause ? 7 * 86400_000 : status === "partial" ? 86400_000 : 3600_000)).toISOString();
18
18
  db.prepare("UPDATE items SET extraction_status = ?, extraction_attempted_at = ?, extraction_retry_at = ? WHERE id = ?")
19
19
  .run(status, new Date().toISOString(), retry, id);
20
20
  }
@@ -73,7 +73,7 @@ export async function executeFullText(userId, itemId, force, priority) {
73
73
  if (result.status !== "ok") {
74
74
  recordAttempt(itemId, result.status);
75
75
  return { ok: false, error: result.status === "failed" ? "could_not_extract_content" : result.status,
76
- ...(result.status === "failed" || result.status === "timeout" ? { retryable: true } : {}) };
76
+ ...(result.status === "timeout" ? { retryable: true } : {}) };
77
77
  }
78
78
  const current = findItemById(itemId);
79
79
  if (!current || current.link !== item.link)
@@ -27,6 +27,7 @@ export function scheduleFullTexts() {
27
27
  AND e.status = 'active' AND e.expires_at > strftime('%Y-%m-%dT%H:%M:%fZ','now')
28
28
  AND i.link IS NOT NULL AND i.full_content_html IS NULL
29
29
  AND i.extraction_status != 'feed_only'
30
+ AND i.extraction_status = 'pending'
30
31
  AND (i.extraction_retry_at IS NULL OR i.extraction_retry_at <= strftime('%Y-%m-%dT%H:%M:%fZ','now'))
31
32
  AND NOT EXISTS (SELECT 1 FROM full_text_jobs j WHERE j.item_id = i.id)
32
33
 
@@ -39,6 +40,7 @@ export function scheduleFullTexts() {
39
40
  AND NOT EXISTS (SELECT 1 FROM subscriptions disabled WHERE disabled.user_id=b.user_id AND disabled.feed_id=i.feed_id AND disabled.full_text_mode='never')
40
41
  AND i.link IS NOT NULL AND i.full_content_html IS NULL
41
42
  AND i.extraction_status != 'feed_only'
43
+ AND i.extraction_status = 'pending'
42
44
  AND (i.extraction_retry_at IS NULL OR i.extraction_retry_at <= strftime('%Y-%m-%dT%H:%M:%fZ','now'))
43
45
  AND NOT EXISTS (SELECT 1 FROM full_text_jobs j WHERE j.item_id = i.id)
44
46
 
@@ -51,6 +53,7 @@ export function scheduleFullTexts() {
51
53
  AND NOT EXISTS (SELECT 1 FROM subscriptions disabled WHERE disabled.user_id=n.user_id AND disabled.feed_id=i.feed_id AND disabled.full_text_mode='never')
52
54
  AND i.link IS NOT NULL AND i.full_content_html IS NULL
53
55
  AND i.extraction_status != 'feed_only'
56
+ AND i.extraction_status = 'pending'
54
57
  AND (i.extraction_retry_at IS NULL OR i.extraction_retry_at <= strftime('%Y-%m-%dT%H:%M:%fZ','now'))
55
58
  AND NOT EXISTS (SELECT 1 FROM full_text_jobs j WHERE j.item_id = i.id)
56
59
 
@@ -63,6 +66,8 @@ export function scheduleFullTexts() {
63
66
  AND COALESCE(s.full_text_mode, 'auto') = 'auto'
64
67
  AND i.link IS NOT NULL AND i.full_content_html IS NULL
65
68
  AND i.extraction_status != 'feed_only'
69
+ AND i.extraction_status = 'pending'
70
+ AND i.created_at >= strftime('%Y-%m-%dT%H:%M:%fZ','now','-14 days')
66
71
  AND (i.extraction_retry_at IS NULL OR i.extraction_retry_at <= strftime('%Y-%m-%dT%H:%M:%fZ','now'))
67
72
  AND NOT EXISTS (SELECT 1 FROM full_text_jobs j WHERE j.item_id = i.id)
68
73
  )
@@ -300,7 +305,7 @@ async function execute(job, host) {
300
305
  return;
301
306
  }
302
307
  if (!result.ok && result.retryable) {
303
- const retryAt = Math.max(Date.now() + 3600_000, result.retryAt ?? 0);
308
+ const retryAt = Math.max(Date.now() + 7 * 86400_000, result.retryAt ?? 0);
304
309
  db.prepare("UPDATE items SET extraction_status=?,extraction_retry_at=? WHERE id=?")
305
310
  .run(result.error === "source_busy" ? "bot_blocked" : "failed", new Date(retryAt).toISOString(), job.item_id);
306
311
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedkeeper/server",
3
- "version": "0.44.1",
3
+ "version": "0.44.3",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }