Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

feat(workers): make monolith timeout and arguments configurable (#2659)

Nikhil Chowdhuryf54a9b8f574f
diff --git a/apps/workers/workers/crawlerWorker.ts b/apps/workers/workers/crawlerWorker.ts
index 0659873b..cfe1288c 100644
--- a/apps/workers/workers/crawlerWorker.ts
+++ b/apps/workers/workers/crawlerWorker.ts
@@ -1435,7 +1435,17 @@ async function archiveWebpage(
: undefined,
no_proxy: serverConfig.proxy.noProxy?.join(","),
},
- })("monolith", ["-", "-Ije", "-t", "5", "-b", url, "-o", assetPath]);
+ })("monolith", [
+ "-",
+ "-Ije",
+ "-t",
+ String(serverConfig.crawler.monolithTimeoutSec),
+ ...serverConfig.crawler.monolithArguments,
+ "-b",
+ url,
+ "-o",
+ assetPath,
+ ]);
if (res.isCanceled) {
logger.error(
diff --git a/docs/docs/03-configuration/01-environment-variables.md b/docs/docs/03-configuration/01-environment-variables.md
index f06a9e81..c55cda94 100644
--- a/docs/docs/03-configuration/01-environment-variables.md
+++ b/docs/docs/03-configuration/01-environment-variables.md
@@ -143,6 +143,8 @@ Either `OPENAI_API_KEY` or `OLLAMA_BASE_URL` need to be set for automatic taggin
| CRAWLER_VIDEO_DOWNLOAD_TIMEOUT_SEC | No | 600 | How long to wait for the video download to finish |
| CRAWLER_ENABLE_ADBLOCKER | No | true | Whether to enable an adblocker in the crawler or not. If you're facing troubles downloading the adblocking lists on worker startup, you can disable this. |
| CRAWLER_YTDLP_ARGS | No | [] | Include additional yt-dlp arguments to be passed at crawl time separated by %%: https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#general-options |
+| CRAWLER_MONOLITH_TIMEOUT_SEC | No | 5 | How long to let monolith run when archiving the full page before timing out (in seconds). Increase this if bookmarks from slow servers frequently fail to archive. Monolith's own default is 120 seconds. |
+| CRAWLER_MONOLITH_ARGS | No | [] | Include additional monolith arguments to be passed when archiving a full page, separated by `%%`. For example, `--no-fonts%%--no-audio%%--no-video` to exclude web fonts, audio, and video from archives. Do not re-specify `-t`, `-b`, or `-o` as these are managed internally. See [monolith options](https://github.com/Y2Z/monolith#command-line-options). |
| BROWSER_COOKIE_PATH | No | Not set | Path to a JSON file containing cookies to be loaded into the browser context. The file should be an array of cookie objects, each with name and value (required), and optional fields like domain, path, expires, httpOnly, secure, and sameSite (e.g., `[{"name": "session", "value": "xxx", "domain": ".example.com"}`]). |
| HTML_CONTENT_SIZE_INLINE_THRESHOLD_BYTES | No | 5 \* 1024 | The thresholds in bytes after which larger assets will be stored in the assetdb (folder/s3) instead of inline in the database. |
diff --git a/packages/shared/config.ts b/packages/shared/config.ts
index 68616c8d..55bfa3c9 100644
--- a/packages/shared/config.ts
+++ b/packages/shared/config.ts
@@ -112,6 +112,11 @@ const allEnv = z.object({
.string()
.default("")
.transform((t) => t.split("%%").filter((a) => a)),
+ CRAWLER_MONOLITH_TIMEOUT_SEC: z.coerce.number().default(5),
+ CRAWLER_MONOLITH_ARGS: z
+ .string()
+ .default("")
+ .transform((t) => t.split("%%").filter((a) => a)),
CRAWLER_PARSER_MEM_LIMIT_MB: z.coerce.number().default(512),
CRAWLER_PARSE_TIMEOUT_SEC: z.coerce.number().default(60),
CRAWLER_SCREENSHOT_TIMEOUT_SEC: z.coerce.number().default(5),
@@ -331,6 +336,8 @@ const serverConfigSchema = allEnv.transform((val, ctx) => {
downloadVideoTimeout: val.CRAWLER_VIDEO_DOWNLOAD_TIMEOUT_SEC,
enableAdblocker: val.CRAWLER_ENABLE_ADBLOCKER,
ytDlpArguments: val.CRAWLER_YTDLP_ARGS,
+ monolithTimeoutSec: val.CRAWLER_MONOLITH_TIMEOUT_SEC,
+ monolithArguments: val.CRAWLER_MONOLITH_ARGS,
parserMemLimitMb: val.CRAWLER_PARSER_MEM_LIMIT_MB,
parseTimeoutSec: val.CRAWLER_PARSE_TIMEOUT_SEC,
screenshotTimeoutSec: val.CRAWLER_SCREENSHOT_TIMEOUT_SEC,