-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket remains open after a timeout #238
Comments
As a workaround fetch the RSS's xml yourself with node's built-in fetch (since v18), axios, etc. const axios = require('axios');
const RSSParser = require('rss-parser');
const parser = new RSSParser();
async function axiosExample(url) {
try {
const response = await axios.get(url);
const feed = await parser.parseString(response.data);
} catch (error) {
console.error("Error fetching the RSS feed:", error);
}
}
async function fetchExample(url) {
) {
try {
// you can also use 'node-fetch' const fetch = require('node-fetch')
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Unexpected response ${response.statusText}`);
}
const xml = await response.text();
const feed = await parser.parseString(xml);
} catch (error) {
console.error("Error fetching the RSS feed:", error);
}
} I made a PR trying to fix this issue (#264) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Node v18.12.1, [email protected]. I am scraping a number of RSS feeds using
rss-parser
. A Nasdaq feed is invariably giving a timeout after 10 seconds, which is the configured time:The feed can be read without issues on a browser so I guess it is limited by user-agent on the server side. Anyway, my program does not terminate properly, and keeps the process open after everything else has been closed. Running it with wtfnode yields the following information:
As it happens, 23.214.214.41 is (not coincidentally) the IP address of the Nasdaq Akamai endpoint:
It appears that
rss-parser
is not closing the socket properly after a timeout. Any ideas?The text was updated successfully, but these errors were encountered: