0

Just getting started with CycleJs and I've hit a wall with this error.

Basically, I'm running the isomorphic example and adding on HTTP Driver so I can send requests

server.js

function wrapAppResultWithBoilerplate(appFn, context$, bundle$) {
  return function wrappedAppFn(sources) {
    const vdom$ = appFn(sources).DOM;
    const wrappedVDOM$ = xs
      .combine(vdom$, context$, bundle$.take(1))
      .map(wrapVTreeWithHTMLBoilerplate)
      .last();
    return Object.assign({}, sources, { DOM: wrappedVDOM$ });
  };
}
...
const context$ = xs.of({ route: req.url });
const wrappedAppFn = wrapAppResultWithBoilerplate(
  app,
  context$,
  clientBundle$
);
run(wrappedAppFn, {
  DOM: makeHTMLDriver(html => res.send(prependHTML5Doctype(html))),
  context: () => context$,
  PreventDefault: () => {},
  HTTP: makeHTTPDriver()
});
...

Stacktrace

TypeError: (intermediate value)(intermediate value)._add is not a function
at MapFlatten._n (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:954:35)
at Stream._n (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1193:22)
at CombineListener._n (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:345:30)
at MemoryStream.Stream._n (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1193:22)
at MemoryStream._n (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:2110:13)
at StartWith._start (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1112:14)
at MemoryStream._add (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:2128:23)
at Combine._start (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:396:14)
at Stream._add (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1250:23)
at MapFlatten._start (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:928:20)
at Stream._add (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1250:23)
at Combine._start (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:396:14)
at Stream._add (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1250:23)
at MapOp._start (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:983:14)
at Stream._add (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1250:23)
at Last._start (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:851:14)
at Stream._add (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1250:23)
at Stream.addListener (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1310:10)
at Stream.subscribe (/Users/jethrolarson/github/isomorphic/node_modules/xstream/src/index.ts:1330:10)
at /Users/jethrolarson/github/isomorphic/node_modules/@cycle/run/src/index.ts:143:54
at Array.map (native)
at replicateMany (/Users/jethrolarson/github/isomorphic/node_modules/@cycle/run/src/index.ts:143:6)
at run (/Users/jethrolarson/github/isomorphic/node_modules/@cycle/run/src/index.ts:230:32)
at run (/Users/jethrolarson/github/isomorphic/node_modules/@cycle/run/src/index.ts:272:10)
at /Users/jethrolarson/github/isomorphic/server.js:105:5
at Layer.handle [as handle_request] (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:317:13)
at /Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:335:12)
at next (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:275:10)
at expressInit (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:317:13)
at /Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:335:12)
at next (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:275:10)
at query (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/middleware/query.js:44:5)
at Layer.handle [as handle_request] (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:317:13)
at /Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:335:12)
at next (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:275:10)
at Function.handle (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/router/index.js:174:3)
at EventEmitter.handle (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/application.js:174:10)
at Server.app (/Users/jethrolarson/github/isomorphic/node_modules/express/lib/express.js:38:9)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
Jethro Larson
  • 2,337
  • 1
  • 24
  • 24

2 Answers2

0

Can you post the source code of wrappedAppFn?

I would suggest double checking that all of the outgoing sinks in wrappedAppFn are indeed Streams.

It seems quite likely that at some point something is expecting a stream and receiving a different type of value.

Widdershin
  • 316
  • 3
  • 10
0

Probably as you appear to be returning sources to run(). The HTTP driver will be getting the wrong type of Stream

This sort of issue is where TypeScript really rocks! If you use an editor like VSCode you'll get type information even you are writing Javascript.

Steve Lee
  • 5,191
  • 5
  • 17
  • 18
  • I hear you about typescript. I tried getting that working but I couldn't get it to compile and the typescript errors were vague and didn't reference anything in my code. – Jethro Larson May 01 '17 at 17:52