rbren / rss-parser

A lightweight RSS parser, for Node and the browser
MIT License
1.39k stars 209 forks source link

Label 'https' has already been declared #186

Closed MorningSleeper closed 3 years ago

MorningSleeper commented 4 years ago

Hi, recently noticed the following in the error log. If it matters, I am not sure which use of rss-parser in my code the error can be traced back to as it is used in multiple places, any ideas as to the cause and how to fix?

rss-parser: 3.9.0 node: 12.19.1

SyntaxError: Label 'https' has already been declared
    at Timeout._onTimeout (/webserver/sites/discordBot/node_modules/rss-parser/lib/utils.js:53:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
11-18-2020 21:16:00.1 [ERROR] Uncaught Exception Error:
SyntaxError: Label 'https' has already been declared
    at Timeout._onTimeout (/webserver/sites/discordBot/node_modules/rss-parser/lib/utils.js:53:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
11-18-2020 21:16:00.1 [ERROR] Uncaught Exception Error:
SyntaxError: Label 'https' has already been declared
    at Timeout._onTimeout (/webserver/sites/discordBot/node_modules/rss-parser/lib/utils.js:53:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
11-18-2020 21:16:00.1 [ERROR] Uncaught Exception Error:
SyntaxError: Label 'https' has already been declared
    at Timeout._onTimeout (/webserver/sites/discordBot/node_modules/rss-parser/lib/utils.js:53:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
11-18-2020 21:16:00.1 [ERROR] Uncaught Exception Error:
SyntaxError: Label 'https' has already been declared
    at Timeout._onTimeout (/webserver/sites/discordBot/node_modules/rss-parser/lib/utils.js:53:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
11-18-2020 21:16:00.1 [ERROR] Uncaught Exception Error:
SyntaxError: Label 'https' has already been declared
    at Timeout._onTimeout (/webserver/sites/discordBot/node_modules/rss-parser/lib/utils.js:53:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
11-18-2020 21:16:00.1 [ERROR] Uncaught Exception Error:
SyntaxError: Label 'https' has already been declared
    at Timeout._onTimeout (/webserver/sites/discordBot/node_modules/rss-parser/lib/utils.js:53:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)

Below is code referenced in error with line 53 noted.

utils.copyFromXML = function(xml, dest, fields) {
  fields.forEach(function(f) {
    let from = f;
    let to = f;
    let options = {};
    if (Array.isArray(f)) {
      from = f[0];
      to = f[1];
      if (f.length > 2) {
        options = f[2];
      }
    }
    const { keepArray, includeSnippet } = options;
    if (xml[from] !== undefined){
      dest[to] = keepArray ? xml[from] : xml[from][0];
    }
    if (dest[to] && typeof dest[to]._ === 'string') {
      dest[to]=dest[to]._;
    }
    if (includeSnippet && dest[to] && typeof dest[to] === 'string') {                      <= Line 53
      dest[to + 'Snippet'] = utils.getSnippet(dest[to]);
    }
  })
}
rbren commented 3 years ago

This is a really strange error. There's nothing in line 53 that should be throwing that error.

It looks like this was inside of a timeout on your end - maybe something went wrong with the error log?

MorningSleeper commented 3 years ago

Ok, thanks for info, I checked the last 7 days of logs and can find no additional occurrences of the reported issue so it appears to have been caused by an issue on my end that has since cleared up.