Skip to content

Commit 5746c2c

Browse files
committed
debug: dns resolution
1 parent 15a1a82 commit 5746c2c

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"sharp": "^0.33.4",
101101
"tailwind-scrollbar": "^3.0.0",
102102
"tailwindcss": "^3.4.0",
103+
"undici": "^7.16.0",
103104
"uuid": "^10.0.0",
104105
"vitest-browser-svelte": "^0.1.0",
105106
"zod": "^3.22.3"

src/routes/api/fetch-url/+server.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { error } from "@sveltejs/kit";
22
import { logger } from "$lib/server/logger.js";
3+
import { fetch } from "undici";
34

45
const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
56
const FETCH_TIMEOUT = 30000; // 30 seconds
@@ -30,7 +31,7 @@ function isValidUrl(urlString: string): boolean {
3031
}
3132
}
3233

33-
export async function GET({ url, fetch }) {
34+
export async function GET({ url }) {
3435
const targetUrl = url.searchParams.get("url");
3536

3637
if (!targetUrl) {
@@ -48,19 +49,13 @@ export async function GET({ url, fetch }) {
4849
const controller = new AbortController();
4950
const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
5051

51-
logger.debug({ targetUrl }, "Fetching url");
5252
const response = await fetch(targetUrl, {
5353
signal: controller.signal,
5454
headers: {
5555
"User-Agent": "HuggingChat-Attachment-Fetcher/1.0",
5656
},
5757
}).finally(() => clearTimeout(timeoutId));
5858

59-
logger.debug(
60-
{ targetUrl, responseHeaders: JSON.stringify(response.headers) },
61-
"URL fetch debug"
62-
);
63-
6459
if (!response.ok) {
6560
logger.error({ targetUrl, response }, `Error fetching URL. Response not ok.`);
6661
throw error(response.status, `Failed to fetch: ${response.statusText}`);

0 commit comments

Comments
 (0)