刚刚开始使用CycleJs,我已经遇到了这个错误。
基本上,我正在运行isomorphic example 并添加HTTP驱动程序,以便我可以发送请求
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()
});
...
堆栈跟踪
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)
答案 0 :(得分:0)
您可以发布wrappedAppFn的源代码吗?
我建议仔细检查wrappedAppFn中的所有传出接收器是否确实是Streams。
似乎很可能在某些时候某些东西期待一个流并接收不同类型的值。
答案 1 :(得分:0)
可能是因为您似乎正在将sources
返回到run()。 HTTP驱动程序将获取错误类型的Stream
这类问题是TypeScript真正摇滚的地方!如果您使用像VSCode这样的编辑器,即使您正在编写Javascript,也会获得类型信息。