Skip to content

Debug Mode ​

How to enable and use debug mode for troubleshooting.

Enabling Debug Mode ​

Add to your .env file:

env
DEBUG=true

Then restart the server:

bash
pm2 restart gradescope-submitter

What 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 --follow

Without PM2 ​

bash
# Run directly and see output
node app.js

Browser Developer Tools ​

Console Tab ​

  1. Open Developer Tools (F12)
  2. Go to Console tab
  3. Look for:
    • JavaScript errors (red)
    • Warnings (yellow)
    • Debug messages (gray)

Network Tab ​

  1. Open Developer Tools (F12)
  2. Go to Network tab
  3. Refresh the page
  4. Look for:
    • Failed requests (red)
    • Slow requests
    • Response codes

Common Network Issues ​

StatusMeaningFix
404Resource not foundCheck URL/path
500Server errorCheck server logs
CORSCross-origin blockedCheck server headers

Debugging Specific Issues ​

LTI Launch Problems ​

Check these in order:

  1. Request received? — Look for POST /lti/launch in logs
  2. Payload valid? — Check for validation errors
  3. Credentials match? — Verify CLIENT_ID and DEPLOYMENT_ID

Gradescope Submission Problems ​

Check these in order:

  1. Code received? — Look for POST /submit in logs
  2. Credentials valid? — Check TOKEN and COOKIE aren't expired
  3. 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 messages

Common 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=false

And restart:

bash
pm2 restart gradescope-submitter

WARNING

Don't leave debug mode on in production — it may expose sensitive information in logs.

Released under the MIT License.