pull-stream / pull-stream

minimal streams
https://pull-stream.github.io/
MIT License
795 stars 78 forks source link

Unclear error when collectAsPromise is given a live stream #143

Open Powersource opened 1 year ago

Powersource commented 1 year ago

Or I think that's the problem anyway. I was just having this discussion with myself in a group chat:

ugh tape is being annoying. this code is failing somehow but i just can't seem to catch the error

  try {
    const excludedUpdate = await pull(
      keyring.group.getUpdates(groupId),
      pull.collectAsPromise()
    ).catch(err=> {
      console.log('excluded list err', err)
      //t.fail(err)
    })
  } catch(err) {
    console.log("why can't exclusion list work?", excludedUpdate, err)
  }

just gives

not ok 38 test exited without ending: getUpdates works
  ---
    operator: fail
    at: process.<anonymous> (/home/me/prj/ssb/ssb-keyring/node_modules/.pnpm/tape@5.6.3/node_modules/tape/index.js:165:8)
    stack: |-
      Error: test exited without ending: getUpdates works
          at Test.assert [as _assert] (/home/me/prj/ssb/ssb-keyring/node_modules/.pnpm/tape@5.6.3/node_modules/tape/lib/test.js:312:48)
          at Test.bound [as _assert] (/home/me/prj/ssb/ssb-keyring/node_modules/.pnpm/tape@5.6.3/node_modules/tape/lib/test.js:95:17)
          at Test.fail (/home/me/prj/ssb/ssb-keyring/node_modules/.pnpm/tape@5.6.3/node_modules/tape/lib/test.js:406:7)
          at Test.bound [as fail] (/home/me/prj/ssb/ssb-keyring/node_modules/.pnpm/tape@5.6.3/node_modules/tape/lib/test.js:95:17)
          at Test._exit (/home/me/prj/ssb/ssb-keyring/node_modules/.pnpm/tape@5.6.3/node_modules/tape/lib/test.js:269:8)
          at Test.bound [as _exit] (/home/me/prj/ssb/ssb-keyring/node_modules/.pnpm/tape@5.6.3/node_modules/tape/lib/test.js:95:17)
          at process.<anonymous> (/home/me/prj/ssb/ssb-keyring/node_modules/.pnpm/tape@5.6.3/node_modules/tape/index.js:165:8)
          at process.emit (node:events:513:28)

apparently because getUpdates is live, so could be called a bug in collectAsPromise (not having a clearer error)

Powersource commented 1 year ago

This got fixed by just adding a pull.take(1) in the middle. Guessing this also happens with collect since collectAsPromise is mostly a wrapper around that.