egg icon indicating copy to clipboard operation
egg copied to clipboard

请求偶尔会报这个错误 Cannot read property 'send' of undefined

Open tomDogwow opened this issue 4 years ago • 3 comments

[2021-07-23 16:35:19.137] [cfork:master:28480] worker:23272 exit (code: null, exitedAfterDisconnect: true, state: dead, isDead: true, isExpected: true, worker.disableRefork: false) [2021-07-23 16:35:19.754] [cfork:master:28480] master uncaughtException: TypeError: Cannot read property 'send' of undefined at Server. (D:\A-EGG\[email protected]@egg-cluster\lib\master.js:219:16) at Server.emit (events.js:310:20) at TCP.onconnection (net.js:1558:8) TypeError: Cannot read property 'send' of undefined at Server. (D:\A-EGG\[email protected]@egg-cluster\lib\master.js:219:16) at Server.emit (events.js:310:20) at TCP.onconnection (net.js:1558:8)

tomDogwow avatar Jul 23 '21 08:07 tomDogwow

Hello @tomDogwow. Please provide a reproducible example following the instruction.

Issues labeled by Need Reproduce will be closed if no activities in 7 days.


@tomDogwow,请根据这个说明提供最小可复现代码。

如果在 7 天内没有进展会被自动关闭。

egg-bot avatar Jul 23 '21 09:07 egg-bot

需提供复现方式,从报错来看,https://github.com/eggjs/egg-cluster/commit/c683b678c2474fca1e9dad8101525c9661177486

atian25 avatar Jul 23 '21 09:07 atian25

需提供复现方式,从报错来看,eggjs/egg-cluster@c683b67

哎 不是百分百出这问题的; 今天中午的时候频繁出现这种情况,因为是开发环境下 每次都需要重启一下或者在代码里敲几下回车在保存才能好,刚刚尝试了半天都没有在出现过这情况,

就只有下面这一个接口爆了好几次这错误; `async order() {

    let query = this.ctx.query;
    let payTime = Math.round(new Date() / 1000);
    var type;
    query.type == 'wechat' ? type = 1 : type = 2;
    let product = query.product;
    if (product == 1 || product == 10 || product == 20 || product == 50) {
        console.log("")
    } else {
        return this.ctx.body = { msg: 'error' }
    };

    let price = query.price
    let param = this.app.jwt.sign(payTime, this.app.config.secret); 
    let sign = '43cc782030f4cfbfc29e2b8b5';

    let sign = md5(payTime + param + type + price + sign);
    let notifyUrl = 'http://xxxx/vpay/paynotify'
    let option = {
        payId: payTime,
        type: type,
        price: price,
        sign: sign,
        param: param,
        notifyUrl: notifyUrl
    }
    let url = `http://xxxx/createOrder`
    try {
        var res = await this.ctx.curl(url, {
            method: 'POST',
            dataType: 'json',
            timeout: 5500,
            data: option
        });
    } catch (error) {
        var err = error;
        console.log('err', err)
        this.ctx.status = 500
        return this.ctx.body = { code: -1, msg: '系统出错,请稍后再试!' }
    };
    console.log(res)
    if (res.data.code === -1) {
        this.ctx.status = 201
        return this.ctx.body = { code: -1, msg: '订单创建失败' }
    }
    let time = dayjs(res.data.date);
    let imgUrl = res.data.data.payUrl
    let timeEnd = time.add(res.data.data.timeOut, 'minute').format('YYYY-MM-DD HH:mm:ss')
    let result = {
        orderid: res.data.data.orderId,
        imgUrl: imgUrl,
        createTime: time.format('YYYY-MM-DD HH:mm:ss'),
        timeOut: timeEnd,
        isAuto: res.data.data.isAuto,
        reallyPrice: res.data.data.reallyPrice
    }
    return this.ctx.body = result
}

`

tomDogwow avatar Jul 23 '21 14:07 tomDogwow