From 815c6f123c3ac0359346562a7bd2445bc7861e0c Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Thu, 4 Dec 2025 15:21:42 -0500 Subject: [PATCH] fix: allow timeout to exit, consistent default options --- src/server.getResources.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/server.getResources.ts b/src/server.getResources.ts index 14f291a8..419d9933 100644 --- a/src/server.getResources.ts +++ b/src/server.getResources.ts @@ -1,7 +1,7 @@ import { readFile } from 'node:fs/promises'; import { join } from 'node:path'; import { getOptions } from './options.context'; -import { RESOURCE_MEMO_OPTIONS } from './options.defaults'; +import { DEFAULT_OPTIONS } from './options.defaults'; import { memo } from './server.caching'; /** @@ -14,7 +14,7 @@ const readLocalFileFunction = async (filePath: string) => await readFile(filePat /** * Memoized version of readLocalFileFunction. Use default memo options. */ -readLocalFileFunction.memo = memo(readLocalFileFunction, RESOURCE_MEMO_OPTIONS.readFile); +readLocalFileFunction.memo = memo(readLocalFileFunction, DEFAULT_OPTIONS.resourceMemoOptions.readFile); /** * Fetch content from a URL with timeout and error handling @@ -26,6 +26,9 @@ const fetchUrlFunction = async (url: string) => { const timeoutMs = Number(process.env.DOC_MCP_FETCH_TIMEOUT_MS || 15_000); const timeout = setTimeout(() => controller.abort(), timeoutMs); + // Allow the process to exit + timeout.unref(); + try { const response = await fetch(url, { signal: controller.signal, @@ -45,7 +48,7 @@ const fetchUrlFunction = async (url: string) => { /** * Memoized version of fetchUrlFunction. Use default memo options. */ -fetchUrlFunction.memo = memo(fetchUrlFunction, RESOURCE_MEMO_OPTIONS.fetchUrl); +fetchUrlFunction.memo = memo(fetchUrlFunction, DEFAULT_OPTIONS.resourceMemoOptions.fetchUrl); /** * Resolve a local path depending on docs host flag