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

Stream implementation issues and incompatibilities #64

Open
LaurensRietveld opened this issue May 11, 2023 · 0 comments
Open

Stream implementation issues and incompatibilities #64

LaurensRietveld opened this issue May 11, 2023 · 0 comments

Comments

@LaurensRietveld
Copy link

The stream implementation is not following the nodejs spec. For instance, when an error even happens at the end of a stream, then the finish event may be emitted before the error event is.

This snippet will first print "finish" and then "error" (and the pipeline promise will resolve instead of reject)

import {pipeline} from "stream/promises"
await pipeline(
  Readable.from("sdfsdf"),
  graphyNtParser()
    .on("error", () => console.log("error"))
    .on("finish", () => console.log("finish"))
);

This is probably causing issues in other places as well. When combining streams (using the experimental compose nodejs builtin, or when using pumpify), we're getting odd behaviour.

This snippet will print function (which is correct, as it's an RDF-JS term)

await pipeline(
  Readable.from("<a:a> <b:b> <c:c> ."),
  graphyNtParser().on("data", (d:any) => {console.log(typeof d.equals)})
);

The snippet below prints object, for both of the on-data handlers. This seems to be JSON (output of the graphy isolate() function). Expecting the same result as above here (RDF-JS), as we're only wrapping the stream in another one

import Pumpify from "pumpify"
await pipeline(
  new Pumpify.obj(
    Readable.from("<a:a> <b:b> <c:c> ."),
    graphyNtParser().on("data", (d:any) => {console.log(typeof d.equals)})
  ),
  new PassThrough({ objectMode: true }).on("data", (d:any) => {console.log(typeof d.equals)})
);

I expect these issues to be caused by extending some stream built-in function such as the pipe function in the graphy stream implementation (which may lead to compatability issues with other streams/stream utilities, as described here)

@LaurensRietveld LaurensRietveld changed the title Stream implementation issues and incompatabilities Stream implementation issues and incompatibilities May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant