ssbc / ssb-config

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

Fix issue where `override` is undefined #20

Closed christianbundy closed 5 years ago

christianbundy commented 5 years ago

It looks like #19 introduced a regression that I found with bench-ssb. This PR resolves the issue.

/home/christianbundy/src/bench-ssb/node_modules/ssb-config/inject.js:15
  var port = override.port || 8008
                      ^

TypeError: Cannot read property 'port' of undefined
    at module.exports (/home/christianbundy/src/bench-ssb/node_modules/ssb-config/inject.js:15:23)
    at module.exports (/home/christianbundy/src/bench-ssb/node_modules/ssb-client/index.js:45:14)
    at /home/christianbundy/src/bench-ssb/09-sbot-replicate.js:30:24
    at /home/christianbundy/src/bench-ssb/node_modules/secure-scuttlebutt/index.js:159:7
    at get (/home/christianbundy/src/bench-ssb/node_modules/flumeview-reduce/inject.js:115:11)
    at /home/christianbundy/src/bench-ssb/node_modules/flumedb/wrap.js:45:11
    at /home/christianbundy/src/bench-ssb/node_modules/flumedb/wrap.js:27:54
    at trigger (/home/christianbundy/src/bench-ssb/node_modules/obv/index.js:17:22)
    at Function.many.set (/home/christianbundy/src/bench-ssb/node_modules/obv/index.js:33:47)
    at /home/christianbundy/src/bench-ssb/node_modules/flumelog-offset/inject.js:60:11

This could also be something like:

var port
if (typeof override === 'object' && override.port) {
  port = override.port
} else {
  port = 8008
}

But it's quite a bit more verbose for (seemingly?) no benefit. Let me know if that's the preference. Thanks!

arj03 commented 5 years ago

Patch looks good, better than the verbose option imo.

cryptix commented 5 years ago

+1 to arj. we might want to consider adding a Schema check around ssb-config. Would clean up this question in a lot of places, I think?

cryptix commented 5 years ago

merging since the sbot tests fail because of this