Fix 500 on all requests: recordVisitor is sync, not a Promise; v2.0.43
Publish Container / docker (push) Successful in 15m4s
Publish Container / docker (push) Successful in 15m4s
server.js was calling recordVisitor(req, res).catch() but recordVisitor returns undefined (it's synchronous). .catch() on undefined throws TypeError on every request, causing Express to return 500 for every page. Swap to try/catch since the function is synchronous. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
6621c45be8
commit
3c62499ad5
2 files changed
+5
-3
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "siteforge",
|
||||
"private": true,
|
||||
"version": "2.0.42",
|
||||
"version": "2.0.43",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -127,9 +127,11 @@ app.use((req, res, next) => {
|
||||
recordHit(req.path, botDetection.isBot, botDetection.reason)
|
||||
queueHitStatsWrite()
|
||||
if (hasVisitorConsent(req) && !botDetection.isBot && !isValidAdminSession(req)) {
|
||||
recordVisitor(req, res).catch(err => {
|
||||
try {
|
||||
recordVisitor(req, res)
|
||||
} catch (err) {
|
||||
console.error('[visitor-stats] failed to record visitor:', err)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
next()
|
||||
|
||||
Reference in new issue
Block a user