ssbc / ssb-config

standard configuration for ssb
MIT License
23 stars 18 forks source link

Fix empty array error caused by reduce() #62

Closed christianbundy closed 4 years ago

christianbundy commented 4 years ago

When there are no interfaces the interfaces variable is set to an empty array, which doesn't play nicely with reduce(). This commit sets the initial value of reduce to [], which lets us concatenate the arrays without throwing a TypeError. The error being solved, which was reported by @powersource:

Uncaught TypeError: Reduce of empty array with no initial value
    at Array.reduce (<anonymous>)
    at eval (incoming-connections.js?7e6a:73)
    at Array.map (<anonymous>)
    at module.exports (incoming-connections.js?7e6a:70)
    at setDefaults (defaults.js?34c4:49)
    at module.exports (inject.js?73a7:7)
    at module.exports (index.js?9885:23)
    at eval (main.js?56d7:9)
    at Module../src/main.js (app.js:992)
    at __webpack_require__ (app.js:786)
Powersource commented 4 years ago

Nice, it seems to get me past that bug (can't verify everything works though because I run into some other bug (probably caused by me))

christianbundy commented 4 years ago

Thanks for the review! I'll merge since it sounds like this is better than not merging. Let me know if you track that bug down to any ssbc code!