|
|
@@ -273,6 +273,36 @@ describe("UrlContentFetcher", () => {
|
|
|
await expect(urlContentFetcher.urlToMarkdown("https://example.com")).rejects.toThrow("Simple string error")
|
|
|
expect(mockPage.goto).toHaveBeenCalledTimes(1)
|
|
|
})
|
|
|
+
|
|
|
+ it("should retry net::ERR_ABORTED like other network errors", async () => {
|
|
|
+ const abortedError = new Error("net::ERR_ABORTED at https://example.com")
|
|
|
+ mockPage.goto.mockRejectedValueOnce(abortedError).mockResolvedValueOnce(undefined)
|
|
|
+
|
|
|
+ const result = await urlContentFetcher.urlToMarkdown("https://example.com")
|
|
|
+
|
|
|
+ expect(mockPage.goto).toHaveBeenCalledTimes(2)
|
|
|
+ expect(mockPage.goto).toHaveBeenNthCalledWith(1, "https://example.com", {
|
|
|
+ timeout: 30000,
|
|
|
+ waitUntil: ["domcontentloaded", "networkidle2"],
|
|
|
+ })
|
|
|
+ expect(mockPage.goto).toHaveBeenNthCalledWith(2, "https://example.com", {
|
|
|
+ timeout: 20000,
|
|
|
+ waitUntil: ["domcontentloaded"],
|
|
|
+ })
|
|
|
+ expect(result).toBe("# Test content")
|
|
|
+ })
|
|
|
+
|
|
|
+ it("should throw error when ERR_ABORTED retry also fails", async () => {
|
|
|
+ const abortedError = new Error("net::ERR_ABORTED at https://example.com")
|
|
|
+ const retryError = new Error("net::ERR_CONNECTION_REFUSED")
|
|
|
+ mockPage.goto.mockRejectedValueOnce(abortedError).mockRejectedValueOnce(retryError)
|
|
|
+
|
|
|
+ await expect(urlContentFetcher.urlToMarkdown("https://example.com")).rejects.toThrow(
|
|
|
+ "net::ERR_CONNECTION_REFUSED",
|
|
|
+ )
|
|
|
+
|
|
|
+ expect(mockPage.goto).toHaveBeenCalledTimes(2)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe("closeBrowser", () => {
|