walinejs / waline

💬 A Simple, Safe Comment System
https://waline.js.org/en/
GNU General Public License v2.0
2.29k stars 404 forks source link

[Bug]: Cannot read properties of undefined (reading 'nick') #2518

Closed jerryc127 closed 6 months ago

jerryc127 commented 6 months ago

问题描述 | Describe the bug

今天遷移waline, 從 vercel + mongodb,遷移到 docker + mysql 數據是從舊的後臺網頁導出,再到新的後臺網頁導入 運行 點擊下一頁加載評論, 出現無法加載。 查看 f12 發現報 Cannot read properties of undefined (reading 'nick')

image image

问题网站 | Website URL

https://butterfly.js.org/messageboard/

服务部署在哪里? | Where your waline deploy?

Docker

数据存储在哪里?| Where your comment data store?

MySQL

lizheming commented 6 months ago

辛苦帮忙提供下 vercel 后台的报错信息帮助下排查吧。


Please help me by providing the error message from the vercel background to help me troubleshoot.

jerryc127 commented 6 months ago

我的 docker logs

情況是, 加載下一頁評論 出現問題 你可以試下網站 https://butterfly.js.org/messageboard/ 到這條評論爲止 點擊 加載更多 報錯 image

waline  | [2024-05-18T21:33:54.862] [1] [INFO] - Server running at http://127.0.0.1:8360
waline  | [2024-05-18T21:33:54.864] [1] [INFO] - ThinkJS version: 3.2.15
waline  | [2024-05-18T21:33:54.864] [1] [INFO] - Environment: production
waline  | [2024-05-18T21:33:54.864] [1] [INFO] - Workers: 1
waline  | [2024-05-18T21:34:00.044] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`url`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id` FROM `wl_Comment` WHERE ( `status` NOT IN ('waiting','spam') ) ORDER BY `insertedAt` DESC LIMIT 0,6, Time: 16ms
waline  | [2024-05-18T21:34:05.814] [14] [INFO] - SQL: SELECT COUNT(*) AS think_count FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) LIMIT 1, Time: 4ms
waline  | [2024-05-18T21:34:05.868] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IS NULL ) ORDER BY `insertedAt` DESC, Time: 53ms
waline  | [2024-05-18T21:34:05.879] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IN (8239,8238,8237,8236,8235,8234,8233,8232) ) ORDER BY `insertedAt` DESC, Time: 4ms
waline  | [2024-05-18T21:34:05.882] [14] [INFO] - SQL: SELECT `display_name`,`email`,`url`,`type`,`avatar`,`label`,`id` FROM `wl_Users` WHERE ( `id` = 41 ), Time: 1ms
waline  | [2024-05-18T21:34:05.886] [14] [INFO] - SQL: SELECT user_id,mail,COUNT(*) as count FROM `wl_Comment` WHERE ( `status` NOT IN ('waiting','spam') ) AND (  ( `user_id` = 41 ) OR ( `mail` IN ('dxyhou@qq.com','my@crazywong.com') ) ) GROUP BY `user_id`,`mail`, Time: 4ms
waline  | [2024-05-18T21:34:07.291] [14] [INFO] - SQL: SELECT COUNT(*) AS think_count FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) LIMIT 1, Time: 4ms
waline  | [2024-05-18T21:34:07.316] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IS NULL ) ORDER BY `insertedAt` DESC, Time: 24ms
waline  | [2024-05-18T21:34:07.333] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IN (8239,8238,8237,8236,8235,8234,8233,8232) ) ORDER BY `insertedAt` DESC, Time: 5ms
waline  | [2024-05-18T21:34:07.335] [14] [INFO] - SQL: SELECT `display_name`,`email`,`url`,`type`,`avatar`,`label`,`id` FROM `wl_Users` WHERE ( `id` = 41 ), Time: 1ms
waline  | [2024-05-18T21:34:07.342] [14] [INFO] - SQL: SELECT user_id,mail,COUNT(*) as count FROM `wl_Comment` WHERE ( `status` NOT IN ('waiting','spam') ) AND (  ( `user_id` = 41 ) OR ( `mail` IN ('dxyhou@qq.com','my@crazywong.com') ) ) GROUP BY `user_id`,`mail`, Time: 6ms
waline  | [2024-05-18T21:34:11.513] [14] [INFO] - SQL: SELECT COUNT(*) AS think_count FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) LIMIT 1, Time: 4ms
waline  | [2024-05-18T21:34:11.537] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IS NULL ) ORDER BY `insertedAt` DESC, Time: 23ms
waline  | [2024-05-18T21:34:11.558] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IN (8231,8230,8228,8226,8225,8224,8222,8220) ) ORDER BY `insertedAt` DESC, Time: 6ms
waline  | [2024-05-18T21:34:11.563] [14] [INFO] - SQL: SELECT user_id,mail,COUNT(*) as count FROM `wl_Comment` WHERE ( `status` NOT IN ('waiting','spam') ) AND (  ( `mail` IN ('289769006@qq.com','804817423@qq.com') ) ) GROUP BY `user_id`,`mail`, Time: 4ms
waline  | [2024-05-18T21:34:15.622] [14] [INFO] - SQL: SELECT COUNT(*) AS think_count FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) LIMIT 1, Time: 3ms
waline  | [2024-05-18T21:34:15.652] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IS NULL ) ORDER BY `insertedAt` DESC, Time: 28ms
waline  | [2024-05-18T21:34:15.667] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IN (8218,8217,8216,8215,8210,8209,8208,8207) ) ORDER BY `insertedAt` DESC, Time: 4ms
waline  | [2024-05-18T21:34:15.671] [14] [INFO] - SQL: SELECT user_id,mail,COUNT(*) as count FROM `wl_Comment` WHERE ( `status` NOT IN ('waiting','spam') ) AND (  ( `mail` = '123456@qq.com' ) ) GROUP BY `user_id`,`mail`, Time: 3ms
waline  | [2024-05-18T21:34:21.714] [14] [INFO] - SQL: SELECT COUNT(*) AS think_count FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) LIMIT 1, Time: 4ms
waline  | [2024-05-18T21:34:21.751] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IS NULL ) ORDER BY `insertedAt` DESC, Time: 36ms
waline  | [2024-05-18T21:34:21.775] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id`,`id` FROM `wl_Comment` WHERE ( `url` = '/messageboard/' ) AND ( `status` NOT IN ('waiting','spam') ) AND ( `rid` IN (8206,8204,8203,8202,8201,8200,8199,8195) ) ORDER BY `insertedAt` DESC, Time: 9ms
waline  | [2024-05-18T21:34:21.777] [14] [INFO] - SQL: SELECT `display_name`,`email`,`url`,`type`,`avatar`,`label`,`id` FROM `wl_Users` WHERE ( `id` IN (25,38) ), Time: 1ms
waline  | [2024-05-18T21:34:21.782] [14] [INFO] - SQL: SELECT user_id,mail,COUNT(*) as count FROM `wl_Comment` WHERE ( `status` NOT IN ('waiting','spam') ) AND (  ( `user_id` IN (25,38) ) OR ( `mail` IN ('adingapkgg@outlook.com','UID_E37BE32756AF4D0709D375DFB365416B@mail.qq','linjinnin11@qq.com') ) ) GROUP BY `user_id`,`mail`, Time: 4ms
waline  | TypeError: Cannot read properties of undefined (reading 'nick')
waline  |     at /app/node_modules/@waline/vercel/src/controller/comment.js:579:28
waline  |     at Array.forEach (<anonymous>)
waline  |     at /app/node_modules/@waline/vercel/src/controller/comment.js:575:24
waline  |     at async Promise.all (index 7)
waline  |     at module.exports.getCommentList (/app/node_modules/@waline/vercel/src/controller/comment.js:544:13)
waline  |     at module.exports.getAction (/app/node_modules/@waline/vercel/src/controller/comment.js:90:18)
waline  |     at cors (/app/node_modules/@koa/cors/index.js:109:16)
waline  |     at /app/node_modules/@waline/vercel/src/middleware/version.js:5:3
waline  |     at /app/node_modules/@waline/vercel/src/middleware/prefix-warning.js:27:3
waline  | [2024-05-18T21:35:10.454] [14] [INFO] - SQL: SELECT `url`,`id` FROM `wl_Comment` WHERE ( `url` IN ('/posts/21cfbf15/','/posts/4-13-release-notes/','/posts/4-12-release-notes/','/posts/4-11-release-notes/','/posts/4-10-release-notes/','/posts/ea33ab97/','/posts/c9711c19/','/posts/507c070f/','/posts/b37b5fe3/','/posts/6ad51b4/') ) AND ( `status` NOT IN ('waiting','spam') ), Time: 5ms
waline  | [2024-05-18T21:35:10.458] [14] [INFO] - SQL: SELECT `status`,`comment`,`insertedAt`,`link`,`mail`,`nick`,`url`,`pid`,`rid`,`ua`,`ip`,`user_id`,`sticky`,`like`,`id` FROM `wl_Comment` WHERE ( `status` NOT IN ('waiting','spam') ) ORDER BY `insertedAt` DESC LIMIT 0,6, Time: 7ms
lizheming commented 6 months ago

可以看下表里的数据,是不是评论数据里,有些有 rid 的,但是没有 pid 呢?


You can look at the data in the table below. Are there comments in the data that have rid but no pid?

jerryc127 commented 6 months ago

可以看下表里的数据,是不是评论数据里,有些有 rid 的,但是没有 pid 呢?

You can look at the data in the table below. Are there comments in the data that have rid but no pid?

沒有 要麽都有值 要麽都是 null

lizheming commented 6 months ago

那就看下是不是 pid 的值是不是都是有效的吧,看对应的评论是否存在?


Then check to see if the pid values ​​are all valid, and see if the corresponding comments exist?

jerryc127 commented 6 months ago

那就看下是不是 pid 的值是不是都是有效的吧,看对应的评论是否存在?

Then check to see if the pid values ​​are all valid, and see if the corresponding comments exist?

我這几千條評論呢 怎麽找

爲啥後臺/ui 界面,加載評論又不會報錯?

lizheming commented 6 months ago

那等之后的优化版本吧,可以先退回老版本处理


Then wait for the optimized version in the future. You can return to the old version first for processing

jerryc127 commented 6 months ago

那等之后的优化版本吧,可以先退回老版本处理

Then wait for the optimized version in the future. You can return to the old version first for processing

你好 你説的老版本是哪一個?

jerryc127 commented 6 months ago

我用 lizheming/waline:1.31.13 正常了


I used lizheming/waline:1.31.13 and it works fine