Skip to content

getStream doesn't emit end event #194

@finwo

Description

@finwo

While trying to fix levelgraph/levelgraph-n3#25 I noticed the getStream method didn't emit an end or close event.

Will provide more details later, including example code to reproduce the issue.

Probably related to #186


Update 2021-12-08

While I was writing a bare-minimum showcase of this bug, everything seemed to work perfectly, not replicating the bug I saw when working on levelgraph-n3.

In the example:

  • db = bare leveldb instance
  • graph = basic levelgraph instance
  • ex = wrapped levelgraph instance, like levelgraph-n3 returns
const level      = require('level-mem');
const levelgraph = require('levelgraph');

const db    = level();
const graph = levelgraph(db);
const ex    = Object.create(graph);

// Insert example data
graph.put([
  {
    subject   : 'hello-world-message',
    predicate : 'type',
    object    : 'message',
  }, {
    subject   : 'hello-world-message',
    predicate : 'content',
    object    : 'Hello World',
  }
]);

db.createReadStream()
  .on('data', chunk => console.log('bare data', {chunk}))
  .on('end', () => console.log('bare end'))

graph.getStream({ subject: 'hello-world-message' })
  .on('data', chunk => console.log('graph data', {chunk}))
  .on('end', () => console.log('graph end'))

ex.getStream({ subject: 'hello-world-message' })
  .on('data', chunk => console.log('ex data', {chunk}))
  .on('end', () => console.log('ex end'))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions