ssbc / secret-stack

connect peers to each other using secret-handshakes
MIT License
90 stars 19 forks source link

Propagate onError #52

Open rogeriochaves opened 4 years ago

rogeriochaves commented 4 years ago

I noticed that secret-stack initiates a multiserver server but passes null as the onError parameter:

https://github.com/ssbc/secret-stack/blob/06305ad1dc2fe302d6d62cb4d05d652995a81683/core.js#L167

as a result sometimes I have this error logged on my app, and there is nothing I can do about it:

Error replicating with @d64Q93XzBhbr2JCLWkZgvzKwTHMvwFgRdtw4fHFlF5k=.ed25519:
   Error: stream ended with:122 but wanted:156
    at drain (/app/node_modules/pull-reader/index.js:43:26)
    at /app/node_modules/pull-reader/index.js:63:18
    at /app/node_modules/pull-reader/index.js:114:13
    at drain (/app/node_modules/stream-to-pull-stream/index.js:126:18)
    at Socket.<anonymous> (/app/node_modules/stream-to-pull-stream/index.js:143:5)
    at Socket.emit (events.js:198:15)
    at Socket.EventEmitter.emit (domain.js:481:20)
    at endReadableNT (_stream_readable.js:1139:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:17)

should we add an onError callback or is there a better way to capture those that I'm not aware of?

arj03 commented 4 years ago

I think that error should be pretty harmless. As for the error handling part, I'm not sure what the best way would be to add it, given how the function is used in the file.