Skip to content

Node 20.11.1 emits deprecation warning DEP0170 #295

@gromnitsky

Description

@gromnitsky

I stumbled upon this while parsing a mastodon feed (I saved the example here). A minimal variant of an unfourtunate feed boils down to

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <link rel="self" href="http://example.com" />
  <entry>
    <link href="tag:mefi.social,2024-01-26:objectId=20368395" />
  </entry>
</feed>

If I parse such xml with feedparser 2.2.1

import FeedParser from 'feedparser'
import {pipeline} from 'stream/promises'
import {createReadStream} from 'fs'

let feedparser = new FeedParser()
await pipeline(createReadStream(process.argv[2]), feedparser)

I get

$ node --throw-deprecation DEP0170.js lol.xml
node:internal/process/warning:185
        throw warning;
        ^

DeprecationWarning: The URL tag:mefi.social,2024-01-26:objectId=20368395 is invalid. Future versions of Node.js will throw an error.
    at getHostname (node:url:516:17)
    at Url.parse (node:url:384:14)
    at urlParse (node:url:141:13)
    at Url.resolve (node:url:722:29)
    at Object.urlResolve [as resolve] (node:url:718:40)
    at /mnt/hdd3/Downloads/DEP0170/node_modules/feedparser/lib/utils.js:148:46
    at Array.forEach (<anonymous>)
    at /mnt/hdd3/Downloads/DEP0170/node_modules/feedparser/lib/utils.js:145:19
    at Array.forEach (<anonymous>)
    at resolveLevel (/mnt/hdd3/Downloads/DEP0170/node_modules/feedparser/lib/utils.js:120:9) {
  code: 'DEP0170'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions