Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop / resume fails with "parser suspended" error #187

Open
alexey-baranov opened this issue May 3, 2018 · 4 comments
Open

stop / resume fails with "parser suspended" error #187

alexey-baranov opened this issue May 3, 2018 · 4 comments

Comments

@alexey-baranov
Copy link

hello! hire is my simple code. it fails with error string "parser suspended"

      parser.on("error", err => {
        logger.error(err)
        //rej(e);
      })

      parser.on("startElement", (name, attrs) => {
        if (name == 'Object' && attrs.LIVESTATUS == 1) {
          logger.debug("stopping...")
          parser.stop()
          models.Zemla.create({
            AOGUID: attrs.AOGUID,
            PARENTGUID: attrs.PARENTGUID ? attrs.PARENTGUID : null,
            SHORTNAME: attrs.SHORTNAME,
            name: attrs.OFFNAME,
            level: attrs.AOLEVEL,
            parent_id: null,
            country_id: RUSSIA
          })
            .then(() => {
              parser.resume()
            })
            .catch(err=>{
              logger.error(attrs, err)
              parser.resume()
            })
        }
      })

      fs.createReadStream(path)
        .pipe(parser);

output

[2018-05-04 00:01:52.930] [DEBUG] FIASImporter - stopping...
[2018-05-04 00:02:02.873] [ERROR] FIASImporter - parser suspended
[2018-05-04 00:02:02.945] [INFO] console - Executing (default): INSERT INTO "Zemla" ("id","AOGUID","PARENTGUID","SHORTNAME","name","level","created_at","updated_at","parent_id","country_id") VALUES (DEFAULT,'d8327a56-80de-4df2-815c-4f6ab1224c50',NULL,'Респ','Адыгея','1','2018-05-03 19:02:02.856 +00:00','2018-05-03 19:02:02.856 +00:00',NULL,1002) RETURNING *;
[2018-05-04 00:02:02.970] [INFO] console - Executing (default): INSERT INTO "ZemlaTree" ("id","deep","created_at","updated_at","menshe_id","bolshe_id") VALUES (DEFAULT,0,'2018-05-03 19:02:02.960 +00:00','2018-05-03 19:02:02.960 +00:00','994251','994251') RETURNING *;

as you can see after first parser.stop() error thrown

@alexey-baranov alexey-baranov changed the title stop / resume fails with stop / resume fails with "parser suspended" error May 3, 2018
@georgyfarniev
Copy link

Yes, I also find it strange, why stop() cause this error? This is not normal behavior I think.

@georgyfarniev
Copy link

I will try to fix this bug and create PR

@georgyfarniev
Copy link

Looks like this is how libexpat works, it notify about stopping via error interface function. So best way is to just ignore this error in your handler. However, it's strange and should be described in docs at least...

@mzedeler
Copy link

mzedeler commented Aug 5, 2019

Also, I suspect that standard tools like pipeline or finished from the mississippi toolkit may fail even though there isn't any error. I would consider not emitting this event as an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants