node.js – MongoError:写EPIPE

我正在使用Node.JS Mongoose MongoDB.我的应用程序到目前为止工作正常,现在在尝试保存文档时:

保存操作:

doc.save(function(err, d){
    console.log(err,d); 

{“name”:”MongoError”,”message”:”write EPIPE”}

错误堆栈:

{ [MongoError: server localhost:27017 received an error {"name":"MongoError","message":"write EPIPE"}]
  name: 'MongoError',
  message: 'server localhost:27017 received an error {"name":"MongoError","message":"write EPIPE"}' } undefined
error: TypeError: Cannot read property 'url' of undefined
    at EventEmitter.<anonymous> (/home/ec2-user/c/index.js:160:61)
    at EventEmitter.<anonymous> (/home/ec2-user/c/node_modules/mongoose/node_modules/mpromise/lib/promise.js:174:48)
    at EventEmitter.emit (events.js:95:17)
    at Promise.safeEmit (/home/ec2-user/c/node_modules/mongoose/node_modules/mpromise/lib/promise.js:81:21)
    at Promise.reject (/home/ec2-user/c/node_modules/mongoose/node_modules/mpromise/lib/promise.js:109:15)
    at Promise.error (/home/ec2-user/c/node_modules/mongoose/lib/promise.js:94:15)
    at Promise.resolve (/home/ec2-user/c/node_modules/mongoose/lib/promise.js:112:24)
    at /home/ec2-user/c/node_modules/mongoose/lib/document.js:1555:39
    at handleError (/home/ec2-user/c/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:40:22)
    at next_ (/home/ec2-user/c/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:75:26)

看起来我能够读取数据,但不能写新文档. Mongo是app并且正在运行.到目前为止,我已经尝试过,重新启动数据库,没有任何好结果.

刚尝试从mongo客户端插入并工作

> db.mysecretcollection.insert({url:"sampletestremoveme"});
WriteResult({ "nInserted" : 1 })

所以它似乎是一个Node.js / Mongoose问题.

最佳答案 在我看来,文档太大了,实际上我可以在删除其中一个字段后保存它.奇怪的是,mongoose应该捕获“错误:文件超过最大允许的bson大小XXX字节”异常,但是从未抛出过.

点赞