Debug Mode
How to enable and use debug mode for troubleshooting.
Enabling Debug Mode
Add to your .env file:
env
DEBUG=trueThen restart the server:
bash
pm2 restart gradescope-submitterWhat Debug Mode Shows
Server Logs
With debug enabled, you'll see detailed logs for:
- Incoming requests
- LTI launch validation
- Gradescope API calls
- Session management
- Error details
Example Debug Output
[DEBUG] POST /submit
[DEBUG] Request body: { code: "print('hello')", asg_id: "6617143" }
[DEBUG] Submitting to Gradescope...
[DEBUG] Course ID: 1106756
[DEBUG] Assignment ID: 6617143
[DEBUG] Response status: 200
[DEBUG] Submission URL: https://gradescope.com/...Viewing Logs
With PM2
bash
# View all logs
pm2 logs
# View only this app's logs
pm2 logs gradescope-submitter
# View last 100 lines
pm2 logs --lines 100
# Follow logs in real-time
pm2 logs --followWithout PM2
bash
# Run directly and see output
node app.jsBrowser Developer Tools
Console Tab
- Open Developer Tools (F12)
- Go to Console tab
- Look for:
- JavaScript errors (red)
- Warnings (yellow)
- Debug messages (gray)
Network Tab
- Open Developer Tools (F12)
- Go to Network tab
- Refresh the page
- Look for:
- Failed requests (red)
- Slow requests
- Response codes
Common Network Issues
| Status | Meaning | Fix |
|---|---|---|
| 404 | Resource not found | Check URL/path |
| 500 | Server error | Check server logs |
| CORS | Cross-origin blocked | Check server headers |
Debugging Specific Issues
LTI Launch Problems
Check these in order:
- Request received? — Look for
POST /lti/launchin logs - Payload valid? — Check for validation errors
- Credentials match? — Verify CLIENT_ID and DEPLOYMENT_ID
Gradescope Submission Problems
Check these in order:
- Code received? — Look for
POST /submitin logs - Credentials valid? — Check TOKEN and COOKIE aren't expired
- API response? — Look for Gradescope response in logs
Pyodide Problems
In browser console, look for:
javascript
// Check if Pyodide loaded
console.log(typeof loadPyodide);
// Check for load errors
// Look for "Pyodide" in console messagesCommon Debug Patterns
Add Temporary Logging
In app.js:
javascript
app.post('/submit', (req, res) => {
console.log('[DEBUG] Submit request:', req.body);
// ... rest of handler
});Check Environment Variables
bash
# Print all env vars (be careful with secrets!)
node -e "console.log(process.env)"
# Check specific variable
node -e "console.log(process.env.COURSE_ID)"Test Gradescope Connection
bash
# Simple test (replace with your values)
curl -X POST https://www.gradescope.com/api/... \
-H "Cookie: your-cookie" \
-d "authenticity_token=your-token"Disabling Debug Mode
When done debugging, remove or set to false:
env
DEBUG=falseAnd restart:
bash
pm2 restart gradescope-submitterWARNING
Don't leave debug mode on in production — it may expose sensitive information in logs.