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 ...
随机推荐
- nginx 安装和配置文件说明
1. 安装依赖包 yum install gcc gcc+ yum install -y pcre pcre-devel openssl openssl-devel zlib zlib-devel 2 ...
- C#基础系列:反射笔记
前言:使用反射也有几年了,但是一直觉得,反这个概念很抽象,今天有时间就来总结下这个知识点. 1.为什么需要反射: 最初使用反射的时候,作为小菜总是不理解,既然可以通过new 一个对象的方式得到对象,然 ...
- 未开启HugePages ORACLE session剧增时引起的一次悲剧
故障简单描写叙述一下:LINUX系统未开启HugePages,主机内存将近300G.SWAP是32G.ORACLE 的 SGA_MAX_SIZE设置是主机内存的将近80%,SGA_TARGET设置是主 ...
- iOS开发工具篇-AppStore统计工具
本文转载至 http://mobile.51cto.com/hot-418183.htm 随着iOS开发的流行,针对iOS开发涉及的方方面面,早有一些公司提供了专门的解决方案或工具.这些解决方案或工具 ...
- Xcode 6 IDE
本文转载至 http://www.cocoachina.com/ios/20140823/9442.html (via:苹果开发者中心) Xcode IDE 是 Apple 开发体验的核心.X ...
- EasyIPCamera实现的桌面采集直播用于课堂、会议、展销同屏等应用
本文转自博客:http://blog.csdn.net/jinlong0603/article/details/56664233 Android同屏直播 在Android上除了获取摄像头数据为Easy ...
- EasyDarwin流媒体服务器实现关键帧推送功能
-本篇由团队成员Fantasy供稿! 功能背景 随着社会进步,人们对产品体验要求越来越高.EasyDarwin也不例外.为了能满足用户对链接服 后看到画面时间(也就是我们经常看到的起播时间)短的要求, ...
- 基于XML配置的Sping AOP详解
一.编写基本处理方法 package com.kang.sping.xml.aop; public class Math{ //加 public int add(int n1,int n2){ int ...
- Hibernate中的Sesson操作
一.Session概述 Session是应用程序与数据库之间的一个会话,是Hibernate运作的中心,持久层操作的基础,相当于JDBC中的Connection.Session对象是通过Session ...
- Extjs-树 Ext.tree.TreePanel 动态加载数据
先上效果图 1.说明Ext.tree.Panel 控件是树形控件,大家知道树形结构在软件开发过程中的应用是很广泛的,树形控件的数据有本地数据.服务器端返回的数据两种.对于本地数据的加载,在extjs的 ...