Cannot set headers after they are sent to the client
D:\le\node_modules\mysql\lib\protocol\Parser.js:
throw err; // Rethrow non-MySQL errors
^ Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the cli
ent
at ServerResponse.setHeader (_http_outgoing.js::)
at ServerResponse.header (D:\le\node_modules\express\lib\response.js::
)
at ServerResponse.send (D:\le\node_modules\express\lib\response.js::
)
at ServerResponse.json (D:\le\node_modules\express\lib\response.js::
)
at ServerResponse.send (D:\le\node_modules\express\lib\response.js::
)
at D:\le\routes\cart.js::
at D:\le\models\cart.js::
at Query._callback (D:\le\models\db.js::)
at Query.Sequence.end (D:\le\node_modules\mysql\lib\protocol\sequences\Se
quence.js::)
at Query.ErrorPacket (D:\le\node_modules\mysql\lib\protocol\sequences\Que
ry.js::)
npm ERR! code ELIFECYCLE
npm ERR! errno
npm ERR! letao@0.0. start: `node ./bin/www`
npm ERR! Exit status
npm ERR!
npm ERR! Failed at the letao@0.0. start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above. npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\administrator\AppData\Roaming\npm-cache\_logs\--28T11_00_46_4
81Z-debug.log D:\letao>
注意其中at Query._callback (D:\le\models\db.js:44:22)找到models\db.js44行
pool.getConnection(function(err, connection) {
if (err) {
// callback(err);
return callback(err);
}
connection.query(sqlStr, params, function(err, rows) {
if (err) {
// callback(err);
return callback(err);
}
connection.release();
callback.apply(null, arguments);//报错行44
});
});
在callback(err)前加return上述错误解决了。具体原因详见参考文章。
参考文章:
https://stackoverflow.com/questions/7042340/error-cant-set-headers-after-they-are-sent-to-the-client
https://cnodejs.org/topic/53774ffecbcc396349ca1155
https://cnodejs.org/topic/5635fed78c67728402553324
https://stackoverflow.com/questions/27658997/cant-set-headers-after-they-are-sent-on-express
Cannot set headers after they are sent to the client的更多相关文章
- Nodejs实现简单的反向代理
var http = require('http'), httpProxy = require('http-proxy'); // 新建一个代理 Proxy Server 对象 var proxy = ...
- c# WebClient文件下载
public void HttpDownload(string url, string path, ResourceType type) { using (var client = new WebCl ...
- webclient的简单实用
这是我在项目中调用别人写好的接口口是使用的1.简单的url传参 List<ArticleModel> result = new List<ArticleModel>(); st ...
- 通过rpc访问比特币核心钱包
开发环境和工具 1. window 10 64 2. 比特核心钱包:bitcoin core 64 配置过程 1. 下载比特币核心钱包,下载链接https://bitcoin.org/en/downl ...
- 用任意语言与WebService进行交互
using System; using System.Web.Services; using YY.SmsPlatform.Common.Objects; using YY.SmsPlatform.C ...
- .net WebClient发送请求实例:
public static Main(string [] ager) { WebClient client = new WebClient(); client.Headers.Clear(); cli ...
- webapi 中使用 protobuf
相比json来说,好处是速度更快,带宽占用更小.其效果大致等于json+Gzip. 在webapi中使用protobuf的方法为: 引用nuget包 Install-Package protobuf- ...
- Getting Started with ASP.NET Web API 2 (C#)
By Mike Wasson|last updated May 28, 2015 7556 of 8454 people found this helpful Print Download Com ...
- WebClient 使用
--post 请求 public static string PostMsg(Guid orgid, int page, int rows) { System.N ...
随机推荐
- 什么是SDN(软件定义网络)(转载)
软件定义网络(Software Defined Network, SDN)在InfoWorld于2011年11月公布的将影响未来10年的十项新技术中排名第二.2012年7月,SDN代表厂商Nicira ...
- Android-运行时权限
由于拨打电话数据用户的隐私,再者由于在5.0之后Android更注重于用户的隐私权限,为此出现了在低版本没有的问题,而在高版本出现的个别问题! Intent intent = new Intent(I ...
- Windows8-x64 VMWare安装Linux CentOS6-x64
本文參考了:http://www.cnblogs.com/seesea125/archive/2012/02/25/2368255.html 其内容相当具体,以至于我还没依照其步骤做完.系统就已经安装 ...
- 面试题三:设计包括 min 函数的栈。
3.设计包括 min 函数的栈. 定义栈的数据结构,要求加入一个 min 函数.可以得到栈的最小元素. 要求函数 min.push 以及 pop 的时间复杂度都是 O(1). 思路分析: a.要想一个 ...
- iOS进程间通信之CFMessagePort
本文转载至 http://www.cocoachina.com/industry/20140606/8701.html iOS系统是出了名的封闭,每个应用的活动范围被严格地限制在各自的沙盒中.尽管如此 ...
- 2016/7/7 设置wamp2.5 mysql密码 重点是mysql版本
密码设置时要注意mysql版本.版本不同,效果不同. 方法/步骤 安装好wamp后,右击wamp->MySQl->MySql console(控制台) 提示输入密码,因为密码为 ...
- 九度OJ 1135:字符串排序 (排序)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1559 解决:807 题目描述: 先输入你要输入的字符串的个数.然后换行输入该组字符串.每个字符串以回车结束,每个字符串少于一百个字符. 如 ...
- Android笔记之dp与px之间的转换以及LayoutParams
dp与px之间的转换公式 px = dp * (dpi / 160) dp = px / (dpi / 160) 其中dpi的获取方式如下 private void getDpi() { Displa ...
- Windows踩坑笔记之使用_tWinMain报错的解决方案
对于如下代码 #include <Windows.h> int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, ...
- 20170306 处理adobe flash player报错
网页总是弹出Adobe Flash Player弹窗报错怎么办?打开网页时经常被Adobe Flash Player报错提示框困扰. 其实是因为系统安装了Debug版本的Flash Player,可是 ...