Skip to content

Debugging Workflow

Fresh

Systematic debugging workflow using Gemini Code Assist.

Debug Decision Tree

mermaid
flowchart TD
    A[Error or bug] --> B{Type?}
    B -->|Syntax or type error| C[Hover error → Quick Fix → /fix]
    B -->|Logic error| D[Select suspect code → Explain this code]
    B -->|Runtime error or exception| E[Paste error + stack into chat]
    C --> F[Review diff → Accept]
    D --> G{Root cause found?}
    G -->|Yes| H[/fix with description]
    G -->|No| E
    E --> I[Chat: How do I fix this?]
    H --> J[Test the fix]
    I --> J
    J --> K{Fixed?}
    K -->|Yes| L[Done]
    K -->|No| M[Agent Mode: deep investigation]
    M --> N[Agent reads files traces execution]
    N --> J

Quick Fix (IDE Errors)

VS Code: Hover squiggly error > Quick Fix > /fix > Accept diff

IntelliJ: Click red error bulb > Fix with Gemini > Accept

Chat Debugging

Paste the complete error with context:

I'm getting this error when calling getUserById():

TypeError: Cannot read property 'id' of undefined
  at UserService.getUserById (/src/services/user.service.ts:45:23)
  at UserController.getUser (/src/controllers/user.controller.ts:12:28)

Here's the code:
[paste the relevant function]

What's causing this and how do I fix it?

Include the full stack trace

Partial errors give partial answers. Always paste the complete stack trace.

Agent-Based Deep Debugging

For complex bugs or race conditions:

Agent: "I have a race condition in the checkout flow — it happens
intermittently when two users submit orders for the same product simultaneously.

Relevant files:
- /src/services/OrderService.ts (the processOrder method)
- /src/services/InventoryService.ts (the decrementStock method)
- /src/tests/checkout.integration.test.ts

Please:
1. Identify the root cause of the race condition
2. Propose a fix (optimistic locking or queue-based)
3. Implement the fix
4. Add a test that reproduces and then verifies the fix"

Debugging Specific Scenarios

API errors

Chat: "This API call returns 401 Unauthorized intermittently.
The token expiry is 1 hour but it fails after 30 minutes.
Here's the auth middleware: [paste code]"

Performance issues

Chat: "This query takes 8 seconds for 1000 records. Here's the ORM query
and the table schema. What's causing it and how do I optimize it?"

Memory leaks

Agent: "Help me find the memory leak in this Node.js service.
Memory grows ~50MB/hour. Start with EventEmitter usage and
closures in /src/workers/ directory."

Based on official Google Gemini Code Assist documentation.