linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
566 stars 146 forks source link

Parsing n-quads throws "callback is not a function" error #323

Closed RinkeHoekstra closed 3 years ago

RinkeHoekstra commented 5 years ago

When trying to parse N-Quads (application/n-quads), rdflib throws an error:

$rdf.parse("<http://ex.com/a> <http://ex.com/b> <http://ex.com/c> <http://ex.com/d> .", $rdf.graph(), "http://ex.com", "application/n-quads");

The error is:

Uncaught TypeError: callback is not a function
    at N3Parser.tripleCallback [as _callback] (rdflib.min.js:25694)
    at N3Parser._readInTopContext (rdflib.min.js:13663)
    at rdflib.min.js:14265
    at N3Lexer._tokenizeToEnd (rdflib.min.js:13291)
    at rdflib.min.js:13529
    at run (rdflib.min.js:17986)
    at runIfPresent (rdflib.min.js:18015)
    at onGlobalMessage (rdflib.min.js:18055)

In some cases the model remains empty, but in other cases some triples do get loaded. I haven't been able to track down exactly where this occurs.

megoth commented 5 years ago

$rdf.parse takes a fifth argument which should be a callback-function. It seems that most of the cases where a missing callback is handled, but some are not.

Have you tried passing a function as the fifth parameter?

RinkeHoekstra commented 5 years ago

Thanks for your suggestion. I'll give it a go and will report back here.

On Thu, 11 Jul 2019 at 15:00, Arne Hassel notifications@github.com wrote:

$rdf.parse takes a fifth argument which should be a callback-function. It seems that most of the cases where a missing callback is handled, but some are not.

Have you tried passing a function as the fifth parameter?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/linkeddata/rdflib.js/issues/323?email_source=notifications&email_token=AAFOSC3B55XHEWBYJ2U3NO3P64VG5A5CNFSM4H62JWR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZWTXIQ#issuecomment-510475170, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFOSC7PSO5YEKHV36KGWMDP64VG5ANCNFSM4H62JWRQ .

RinkeHoekstra commented 3 years ago

Works (apologies for the delay in reporting back)