Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/server.getResources.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down
Loading