如何在Node.js中处理超时(--ms--消息)

时间:2019-02-23 09:24:48

标签: javascript node.js express

此照片显示to_frame(filter_observations=True) 条消息。在客户端,我收到DataFrame.sum(axis=None, skipna=None, level=None, numeric_only=None, min_count=0, **kwargs) 错误。

enter image description here

我试图弄清楚它的发生位置,以及为什么使用--ms--timeout的原因,但是找不到。

这是'routes / email.js'

try-catch

console.log部分根本不执行。

这是var express = require('express'); var router = express.Router(); var db = require('../db'); var nodemailer = require("nodemailer"); var smtpTransport = nodemailer.createTransport({ service: 'Gmail', auth: { user: 'ssssss@gmail.com', pass: 'SSSSSS' } }); router.get('/send', function(req, res, next) { console.log('/send'); var email = decodeURI(req.query.to); console.log(email); var rand = Math.floor((Math.random() * 9000 + 1000)); var link="http://"+req.get("host")+"/email/verify?email="+email+"&num="+rand; var mailOptions={ to : email, subject : "Please confirm your Email account", html : "Hello,<br> Please Click on the link to verify your email.<br><a href="+link+">Click here to verify</a>" } try{ smtpTransport.sendMail(mailOptions, function(error, response){ if(error){ console.log(error); res.json({result:false,message:"Incorrect email", code:404}); }else{ console.log("Message sent:\n"+JSON.stringify(response, null, 2)); try{ console.log(JSON.stringify(db, null, 2)); var sql = "INSERT INTO email_verification(email, code) VALUES(?,?)"; var input = [email, rand]; db.get().query(sql, input, function(err, result){ if(err) res.json({result:false, message:"SQL error", code:403}); res.json({result:true, message:"Please check your email.", code:100}); }); // res.json({result:false, message:"DB ERROR", code:401}); }catch(e){ console.log(e); } } }); }catch(e){ console.log(e); } }); module.exports = router;

db.get().query()

db.js部分工作正常。

这是const mariadb = require('mariadb'); var pool; exports.connect = function(done){ console.log("Trying to connect DB..."); pool = mariadb.createPool({ host: 'localhost', user: 'root', password: 'ssss', database:"SSSS", connectionLimit: 100 }); } exports.get = function(){ console.log("exports.get"); return pool; }

console.log("exports.get");

我刚刚使用了我其他项目中的app.jsvar createError = require('http-errors'); var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var logger = require('morgan'); var db = require('./db'); //var passport = require('./passport'); //var auth = require('./routes/auth'); var app = express(); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); db.connect(function(err){ console.log(err); if(err){ console.log('Unable to connect to MariaDB.'); process.exit(1); } }); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', require("./routes/index")); app.use('/email', require("./routes/email")); // catch 404 and forward to error handler app.use(function(req, res, next) { var err = new Error('Not Found'); err.status = 404; next(404); }); // error handler app.use(function(err, req, res, next) { // set locals, only providing error in development res.locals.message = err.message; res.locals.error = req.app.get('env') === 'development' ? err : {}; // render the error page res.status(err.status || 500); res.render('error'); }); module.exports = app; 文件,在那儿工作正常。但是我不知道为什么这次我有这个问题。

哪一部分以及为什么出现此问题以及如何解决?

  • 如果我可以轻松跟踪错误,则使用no​​de.js会更容易。找出有问题的部分需要很多时间。是否有任何模块或工具?

0 个答案:

没有答案