【问题标题】:caolon async - callback never gets calledcaolon async - 回调永远不会被调用
【发布时间】:2013-11-23 06:02:13
【问题描述】:

我正在使用瀑布模型一个接一个地调用函数列表。在上传 req.on 'data' 期间永远不会被调用。下面是代码。发生了什么。

app.post '/upload', (req,res)->
    uploadFile = (cb)->
            req.on 'data', (chunk)->
                console.log "In the on data"+file ""NEVER GETS CALLED.
                console.log chunk
                file.write chunk
            req.on 'end', ->
                file.end()
                console.log "Wrote file"
                cb(null)

    async.waterfall [uploadFile],(err,result)->

【问题讨论】:

  • 如果您使用的是express.bodyParser,那将已经读取了传入的数据。此外,在此示例中使用 async.waterfall 并不是很有用。
  • 代码很简单,可以看穿问题(还有其他例程需要调用)。也没有 express.bodyParser 的问题,因为如果我将其移出 async.waterfall,代码将正常工作

标签: node.js asynchronous express coffeescript


【解决方案1】:

如果您无法升级到最新的 nodejs,请使用 mjijackson 的 bufferedstream

【讨论】:

    猜你喜欢
    • 2012-02-18
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 2018-08-08
    • 1970-01-01
    • 1970-01-01
    • 2020-11-18
    • 1970-01-01
    相关资源
    最近更新 更多