Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Issue with parseString in the new API? #34

meetamit opened this Issue · 2 comments

2 participants


Hi there,

(I'm trying out this module for the first time)

Running this very simple example:

var feedparser = require('feedparser');
  .on('article', console.log);

The Issue: The event handler (console.log) never gets invoked.

As I understand it, that's because the string is already parsed by the time on() gets to register the event handler. To prove it, I modified FeedParser.parseString() in the feedparser source with a setTimeout like so:

FeedParser.parseString = function (string, options, callback) {
  var fp = feedparser(options, callback);
  setTimeout(function() {
      .on('error', fp.handleError.bind(fp))
      .end(string, Buffer.isBuffer(string) ? null : 'utf8'); // Accomodate a Buffer in addition to a String
  return fp;

and indeed, this made things work. Am I misunderstanding something?

PS: I'm running feedparser v0.10.6 with node.js v0.8.8.

@danmactough danmactough referenced this issue from a commit
@danmactough Fix issue #34 .parseString() emitting too soon. All `emit()` and `cal…
…lback()` are wrapped in `process.nextTick()`. Bump version.

Thanks for the report. I was already tinkering with this, but I wasn't able to make it fail to prove it was an issue. You gave me a reason to push this change!

@danmactough danmactough closed this

Thanks! And... I learned something new from this; I didn't know about process.nextTick()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.