invisible-college / statebus

All aboard the STATEBUS!!!
118 stars 5 forks source link

Saving/fetching state on a statebus server produces errors #37

Closed karth295 closed 6 years ago

karth295 commented 6 years ago
$ cat foo.js
var bus = require('statebus').serve({})
state.foo = 'bar';
console.log(state.foo);

Running foo.js as sudo node foo.js:

TypeError: Cannot read property '0' of null
  at bus.http_serve (/home/karthik/tawk.space/node_modules/statebus/server.js:1728:55)
  at textbus.to_fetch (/home/karthik/tawk.space/node_modules/statebus/server.js:1703:24)
  at /home/karthik/tawk.space/node_modules/statebus/statebus.js:800:31  
  at funk (/home/karthik/tawk.space/node_modules/statebus/statebus.js:918:35) 
  at Function.run_handler (/home/karthik/tawk.space/node_modules/statebus/statebus.js:856:16)
  at bus.route (/home/karthik/tawk.space/node_modules/statebus/statebus.js:867:17)  
  at Function.bus.route (/home/karthik/tawk.space/node_modules/statebus/statebus.js:1662:20)
  at Function.fetch (/home/karthik/tawk.space/node_modules/statebus/statebus.js:51:31)
  at pget (/home/karthik/tawk.space/node_modules/statebus/statebus.js:1218:21)
  at Object.get (/home/karthik/tawk.space/node_modules/statebus/statebus.js:1346:28)
toomim commented 6 years ago

Fixed! Thanks Karthik! The global state variable was getting clobbered on the server. 204dca8570b873c21042d4bdc7beec234c30fb7d