Refactir
This commit is contained in:
parent
d25a2d9b68
commit
75e5c4600f
132
MARK_ALL_READ_DIAGNOSTIC.md
Normal file
132
MARK_ALL_READ_DIAGNOSTIC.md
Normal file
@ -0,0 +1,132 @@
|
||||
# Mark All As Read - Diagnostic Guide
|
||||
|
||||
**Issue**: Adapter returns `false` but no detailed logs appear
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Current Situation
|
||||
|
||||
**What We See**:
|
||||
```
|
||||
[NOTIFICATION_SERVICE] Adapter leantime markAllAsRead result: false
|
||||
[NOTIFICATION_SERVICE] markAllAsRead results: [ false ]
|
||||
[NOTIFICATION_SERVICE] markAllAsRead overall success: false
|
||||
```
|
||||
|
||||
**What's Missing**:
|
||||
- `[NOTIFICATION_SERVICE] markAllAsRead called for user ...`
|
||||
- `[NOTIFICATION_SERVICE] Processing adapter: leantime`
|
||||
- `[NOTIFICATION_SERVICE] Calling markAllAsRead on adapter leantime`
|
||||
- `[LEANTIME_ADAPTER] ===== markAllAsRead START =====` ← **NEW: Very prominent marker**
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Possible Causes
|
||||
|
||||
### 1. Server Not Fully Restarted
|
||||
**Solution**: Do a **hard restart**:
|
||||
```bash
|
||||
# Stop completely
|
||||
sudo npm stop
|
||||
# Or kill the process
|
||||
sudo pkill -f "next start"
|
||||
|
||||
# Wait a few seconds
|
||||
sleep 3
|
||||
|
||||
# Start fresh
|
||||
sudo npm start
|
||||
```
|
||||
|
||||
### 2. Next.js Build Cache
|
||||
**Solution**: Clear cache and rebuild:
|
||||
```bash
|
||||
rm -rf .next
|
||||
sudo npm start
|
||||
```
|
||||
|
||||
### 3. Log Buffering/Filtering
|
||||
**Solution**: Check if logs are being filtered. Look for ALL logs around the mark-all-as-read operation.
|
||||
|
||||
### 4. Code Not Deployed
|
||||
**Solution**: Verify the file was saved and the server picked it up.
|
||||
|
||||
---
|
||||
|
||||
## ✅ What to Look For After Restart
|
||||
|
||||
### Expected Complete Log Flow
|
||||
|
||||
When you click "Mark all as read", you should see **ALL** of these logs:
|
||||
|
||||
```
|
||||
[NOTIFICATION_API] Mark all as read endpoint called
|
||||
[NOTIFICATION_API] Mark all as read - Processing { userId: '...', timestamp: '...' }
|
||||
[NOTIFICATION_SERVICE] markAllAsRead called for user ...
|
||||
[NOTIFICATION_SERVICE] Available adapters: leantime
|
||||
[NOTIFICATION_SERVICE] Processing adapter: leantime
|
||||
[NOTIFICATION_SERVICE] Adapter leantime is configured: true
|
||||
[NOTIFICATION_SERVICE] Calling markAllAsRead on adapter leantime
|
||||
[LEANTIME_ADAPTER] ===== markAllAsRead START ===== ← VERY PROMINENT
|
||||
[LEANTIME_ADAPTER] markAllAsRead called for userId: ...
|
||||
[LEANTIME_ADAPTER] API URL: ...
|
||||
[LEANTIME_ADAPTER] Has API Token: true
|
||||
[LEANTIME_ADAPTER] markAllAsRead - User email: ...
|
||||
[LEANTIME_ADAPTER] markAllAsRead - Leantime user ID: ...
|
||||
[LEANTIME_ADAPTER] markAllAsRead - Request body: {...}
|
||||
[LEANTIME_ADAPTER] markAllAsRead - API URL: ...
|
||||
[LEANTIME_ADAPTER] markAllAsRead - Response status: XXX
|
||||
[LEANTIME_ADAPTER] markAllAsRead - Response body: {...}
|
||||
[LEANTIME_ADAPTER] markAllAsRead - Parsed response: {...}
|
||||
[LEANTIME_ADAPTER] markAllAsRead - API Error: {...} ← This will show the actual error
|
||||
[LEANTIME_ADAPTER] ===== markAllAsRead END (success: false) =====
|
||||
[NOTIFICATION_SERVICE] Adapter leantime markAllAsRead result: false
|
||||
[NOTIFICATION_SERVICE] markAllAsRead results: [ false ]
|
||||
[NOTIFICATION_SERVICE] markAllAsRead overall success: false
|
||||
[NOTIFICATION_SERVICE] Not invalidating caches - operation failed
|
||||
[NOTIFICATION_API] Mark all as read - Failed { userId: '...', duration: '...ms' }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Critical Check
|
||||
|
||||
**After restarting**, search your logs for:
|
||||
```
|
||||
===== markAllAsRead START =====
|
||||
```
|
||||
|
||||
If you **DON'T** see this line, the adapter method is **NOT** being called, which means:
|
||||
- Server not restarted properly
|
||||
- Code not deployed
|
||||
- Different code path being used
|
||||
|
||||
If you **DO** see this line, we'll have all the details we need to fix the Leantime API call.
|
||||
|
||||
---
|
||||
|
||||
## 📋 Action Items
|
||||
|
||||
1. ✅ **Hard Restart Server** (stop completely, wait, start)
|
||||
2. ✅ **Test Mark All As Read**
|
||||
3. ✅ **Search logs for `===== markAllAsRead START =====`**
|
||||
4. ✅ **Share ALL logs** from the mark-all-as-read operation
|
||||
5. ✅ **Look for `API Error:`** in the logs (this will show what Leantime is returning)
|
||||
|
||||
---
|
||||
|
||||
## 🔧 If Logs Still Don't Appear
|
||||
|
||||
If after restart you still don't see the `===== markAllAsRead START =====` log:
|
||||
|
||||
1. **Verify file was saved**: Check `lib/services/notifications/leantime-adapter.ts` line 220-224
|
||||
2. **Check for syntax errors**: Run `npm run build` or check for TypeScript errors
|
||||
3. **Verify server is using the file**: Check if there are multiple versions or build artifacts
|
||||
4. **Check log output**: Make sure you're looking at the right log file/stream
|
||||
|
||||
---
|
||||
|
||||
**Status**: Enhanced logging with prominent markers added. Awaiting server restart and test.
|
||||
|
||||
**Next**: After restart, the `===== markAllAsRead START =====` marker will confirm the method is being called, and we'll see the exact Leantime API error.
|
||||
|
||||
@ -217,7 +217,11 @@ export class LeantimeAdapter implements NotificationAdapter {
|
||||
}
|
||||
|
||||
async markAllAsRead(userId: string): Promise<boolean> {
|
||||
console.log(`[LEANTIME_ADAPTER] markAllAsRead called for ${userId}`);
|
||||
// CRITICAL: This should ALWAYS appear if method is called
|
||||
console.log(`[LEANTIME_ADAPTER] ===== markAllAsRead START =====`);
|
||||
console.log(`[LEANTIME_ADAPTER] markAllAsRead called for userId: ${userId}`);
|
||||
console.log(`[LEANTIME_ADAPTER] API URL: ${this.apiUrl}`);
|
||||
console.log(`[LEANTIME_ADAPTER] Has API Token: ${!!this.apiToken}`);
|
||||
|
||||
try {
|
||||
// Get user email and ID
|
||||
@ -291,10 +295,12 @@ export class LeantimeAdapter implements NotificationAdapter {
|
||||
|
||||
const success = data.result === true || data.result === "true" || !!data.result;
|
||||
console.log(`[LEANTIME_ADAPTER] markAllAsRead - Success: ${success}`);
|
||||
console.log(`[LEANTIME_ADAPTER] ===== markAllAsRead END (success: ${success}) =====`);
|
||||
return success;
|
||||
} catch (error) {
|
||||
console.error('[LEANTIME_ADAPTER] markAllAsRead - Exception:', error);
|
||||
console.error('[LEANTIME_ADAPTER] markAllAsRead - Error stack:', error instanceof Error ? error.stack : 'No stack');
|
||||
console.error(`[LEANTIME_ADAPTER] ===== markAllAsRead END (exception) =====`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user