Troubleshooting

Common Issues and Solutions

1. Database Connection Failed

Error:

Unable to connect Osas database: SequelizeConnectionError

Solutions:

2. JWT Token Invalid

Error:

{
  "message": "Unauthorized",
  "error": "Invalid token"
}

Solutions:

3. Rate Limit Exceeded

Error:

{
  "message": "You are sending requests too quickly. Please wait 1 second."
}

Solutions:

4. File Upload Failed

Error:

{
  "message": "File too large"
}

Solutions:

5. Courier Webhook Not Working

Error: Webhooks not updating status

Solutions:

6. Fee Calculation Returns 0

Error:

{
  "fee": 0
}

Solutions:

7. Sequelize Migration Issues

Error:

SequelizeDatabaseError: relation does not exist

Solutions:

8. CORS Errors

Error:

Access to fetch blocked by CORS policy

Solutions:

9. Image Not Loading

Error: 404 on image URLs

Solutions:

10. Cron Job Not Running

Error: Lion Parcel pickup not scheduling

Solutions:

Debug Mode

Enable Verbose Logging:

// Add to ondeliv-backend.js temporarily
app.use((req, res, next) => {
  console.log(`${req.method} ${req.url}`);
  console.log('Headers:', req.headers);
  console.log('Body:', req.body);
  next();
});

Database Query Logging:

// In db.config.js
module.exports = {
  // ... existing config
  logging: console.log,  // Enable SQL query logging
};

Health Check Endpoint

Check Server Status:

curl http://localhost:4220/

Expected Response:

{
  "message": "This backend osas works well for now"
}

Performance Monitoring

Check Database Connection:

// Test database connectivity
const testConnection = async () => {
  try {
    await db.sequelize.authenticate();
    console.log('Database connected');
  } catch (error) {
    console.error('Database connection failed:', error);
  }
};

Monitor Response Times:

Morgan logs include response time in cyan color.

Getting Help

Resources:

Contact:


Revision #1
Created 24 February 2026 07:03:33 by ondeliveloper
Updated 24 February 2026 07:04:06 by ondeliveloper