Skip to content

Commit fa5c734

Browse files
authored
fix: allow process to exit, consistent imports (#32)
1 parent 51bbc31 commit fa5c734

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/server.getResources.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFile } from 'node:fs/promises';
22
import { join } from 'node:path';
33
import { getOptions } from './options.context';
4-
import { RESOURCE_MEMO_OPTIONS } from './options.defaults';
4+
import { DEFAULT_OPTIONS } from './options.defaults';
55
import { memo } from './server.caching';
66

77
/**
@@ -14,7 +14,7 @@ const readLocalFileFunction = async (filePath: string) => await readFile(filePat
1414
/**
1515
* Memoized version of readLocalFileFunction. Use default memo options.
1616
*/
17-
readLocalFileFunction.memo = memo(readLocalFileFunction, RESOURCE_MEMO_OPTIONS.readFile);
17+
readLocalFileFunction.memo = memo(readLocalFileFunction, DEFAULT_OPTIONS.resourceMemoOptions.readFile);
1818

1919
/**
2020
* Fetch content from a URL with timeout and error handling
@@ -26,6 +26,9 @@ const fetchUrlFunction = async (url: string) => {
2626
const timeoutMs = Number(process.env.DOC_MCP_FETCH_TIMEOUT_MS || 15_000);
2727
const timeout = setTimeout(() => controller.abort(), timeoutMs);
2828

29+
// Allow the process to exit
30+
timeout.unref();
31+
2932
try {
3033
const response = await fetch(url, {
3134
signal: controller.signal,
@@ -45,7 +48,7 @@ const fetchUrlFunction = async (url: string) => {
4548
/**
4649
* Memoized version of fetchUrlFunction. Use default memo options.
4750
*/
48-
fetchUrlFunction.memo = memo(fetchUrlFunction, RESOURCE_MEMO_OPTIONS.fetchUrl);
51+
fetchUrlFunction.memo = memo(fetchUrlFunction, DEFAULT_OPTIONS.resourceMemoOptions.fetchUrl);
4952

5053
/**
5154
* Resolve a local path depending on docs host flag

0 commit comments

Comments
 (0)