rowanmanning / feed-parser

A well-tested and resilient Node.js parser for RSS and Atom feeds.
MIT License
7 stars 1 forks source link

Getting error when trying to access `published` attribute of the feed item #123

Closed oussama-he closed 6 months ago

oussama-he commented 6 months ago

I'm getting the error below when trying to access the published attribute of the feed item:

Uncaught Error: `new Date()` with non-number arguments is not supported.
    at get textContentAsDate [as textContentAsDate] (../../node_modules/@rowanmanning/feed-parser/lib/xml/element.js:207:3)
    at get published [as published] (../../node_modules/@rowanmanning/feed-parser/lib/feed/item/rss.js:66:1)

My code looks like this:

const projects = [];

    for (let item of parseFeed(feed).items) {
      projects.push({
        'title': `${item.title}`,
        'description': `${item.description}`,
        'url': `${item.url}`,
        'pubDate': `${item.published}`
      })
    }
rowanmanning commented 6 months ago

Hi 👋 could you share the feed that you're trying to parse?

oussama-he commented 6 months ago

I'm trying to parse this feed: https://mostaql.com/rss

On Sat, May 11, 2024, 11:27 Rowan Manning @.***> wrote:

Hi 👋 could you share the feed that you're trying to parse?

— Reply to this email directly, view it on GitHub https://github.com/rowanmanning/feed-parser/issues/123#issuecomment-2105667610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMSLY5NWUNRFCJNT5LGBODZBXXB3AVCNFSM6AAAAABHRZNAJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBVGY3DONRRGA . You are receiving this because you authored the thread.Message ID: @.***>

rowanmanning commented 6 months ago

Odd I'm unable to replicate this, the feed parses fine for me and I'm able to access the published property of all items. Could you let me know the following:

oussama-he commented 6 months ago

Thank you for your response and sorry to be late.

When you asked me about the Node.js version, I checked the runtime version used in the service I'm using. I found that they use by default a custom JavaScript runtime very similar to the Cloudflare Workers runtime. When I changed it to Node.js runtime the error disappeared.