Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Liam Dyer
commited on
Log parsing failures, drop from UI (#1189)
Browse files
src/lib/server/websearch/scrape/scrape.ts
CHANGED
@@ -5,8 +5,9 @@ import { withPage } from "./playwright";
|
|
5 |
import { spatialParser } from "./parser";
|
6 |
import { htmlToMarkdownTree } from "../markdown/tree";
|
7 |
import { timeout } from "$lib/utils/timeout";
|
8 |
-
import {
|
9 |
import { MetricsServer } from "$lib/server/metrics";
|
|
|
10 |
|
11 |
export const scrape = (maxCharsPerElem: number) =>
|
12 |
async function* (
|
@@ -20,12 +21,14 @@ export const scrape = (maxCharsPerElem: number) =>
|
|
20 |
|
21 |
MetricsServer.getMetrics().webSearch.pageFetchDuration.observe(Date.now() - startTime);
|
22 |
|
23 |
-
yield makeGeneralUpdate({
|
|
|
|
|
|
|
24 |
return { ...source, page };
|
25 |
} catch (e) {
|
26 |
MetricsServer.getMetrics().webSearch.pageFetchCountError.inc();
|
27 |
-
|
28 |
-
yield makeErrorUpdate({ message: "Failed to parse webpage", args: [message, source.link] });
|
29 |
}
|
30 |
};
|
31 |
|
|
|
5 |
import { spatialParser } from "./parser";
|
6 |
import { htmlToMarkdownTree } from "../markdown/tree";
|
7 |
import { timeout } from "$lib/utils/timeout";
|
8 |
+
import { makeGeneralUpdate } from "../update";
|
9 |
import { MetricsServer } from "$lib/server/metrics";
|
10 |
+
import { logger } from "$lib/server/logger";
|
11 |
|
12 |
export const scrape = (maxCharsPerElem: number) =>
|
13 |
async function* (
|
|
|
21 |
|
22 |
MetricsServer.getMetrics().webSearch.pageFetchDuration.observe(Date.now() - startTime);
|
23 |
|
24 |
+
yield makeGeneralUpdate({
|
25 |
+
message: "Browsing webpage",
|
26 |
+
args: [source.link],
|
27 |
+
});
|
28 |
return { ...source, page };
|
29 |
} catch (e) {
|
30 |
MetricsServer.getMetrics().webSearch.pageFetchCountError.inc();
|
31 |
+
logger.debug(`Error scraping webpage: ${source.link}`, { error: e });
|
|
|
32 |
}
|
33 |
};
|
34 |
|