Open RodrigoTomeES opened 11 months ago
@littledivy I think the problem is related with the asynchrony because this version of the code works well.
import { load as loadEnv } from "https://deno.land/std@0.208.0/dotenv/mod.ts";
import Sitemapper from "npm:sitemapper";
await loadEnv({ export: true });
const Website = new Sitemapper({
url: Deno.env.get("SITEMAP"),
timeout: 15000,
});
try {
const { sites } = await Website.fetch();
const report = [];
for (const url of sites) {
try {
await (await fetch(url)).text();
report.push(true);
} catch (error) {
console.error(error);
}
}
const urls = sites.length;
const total = report.length;
console.log(`Total: ${total}/${urls}, skipped: ${urls - total}`);
} catch (error) {
console.error(error);
}
I think I found the issue, the problem is related with the number of asynchronous functions (650 more or less). In node only about 10-15 calls fails but in Deno almost. I will change the code to launch the fetch in async but with a limit of number of concurrent calls.
Despite all this, I think Deno should handle this better or release a clearer bug about the issue.
Version: Deno 1.38.5
This is an example that when you run it throw the error
TypeError: error sending request for url (https://resa.es/en/residences/madrid/erasmo/): http2 error: stream error received: refused stream before processing any application logic
. If you try to fetch that url individually it works but when you run the script a lot of pages failed.Total: 177/621, skipped: 444
.env
main.ts
EDIT: I updated the code with a minimal reproduction