mozilla / readability

A standalone version of the readability lib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error during parse | TypeError: Cannot read properties of null

bradonomics opened this issue · comments

I'm getting the below error when parsing articles on coryzue.com.

TypeError: Cannot read properties of null (reading 'content')
    at app/lib/readability.js:11:25
    at Object.readFileAfterClose (node:internal/fs/read_file_context:68:3)
    at tick (node:internal/fs/read_file_context:115:9)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

The app/lib/readability.js file above looks like this:

var fs = require('fs');
var { Readability } = require('@mozilla/readability');
var JSDOM = require('jsdom').JSDOM;

try {
  fs.readFile(0, 'utf8', function(err, data) {
    if (err) throw err;
    var doc = new JSDOM(data, { url: process.argv.slice(2) });
    var article = new Readability(doc.window.document).parse();
    console.log(article.content);
  });
} catch (error) {
  console.log(error instanceof TypeError);
}

Hey there, apologies for the delay in a response here. We've tried to reproduce this and aren't seeing anything on the page that stands out as an issue. Is this still an issue you're encountering, and is it possible that you might have an older JSDOM version?