Overview
When debugging Prisma Engines, you have several tools and techniques at your disposal:- Language server support for code navigation
- Debug macros and logging
- Environment variable controls
- Query graph visualization
- Test runners with detailed output
General Debugging Techniques
Use the Language Server
The Rust language server (rust-analyzer) is invaluable for:- Go to definition - Navigate to function/type definitions
- Find references - Locate all usages of a symbol
- Type information - Understand complex type hierarchies
- Inline errors - See compilation errors in real-time
Debug Print Statements
Use Rust’sdbg!() macro to inspect variables and validate code paths:
dbg!() macro:
- Prints to stderr with file and line number
- Returns the value, so it can be used inline
- Pretty-prints the debug representation
Add Logging Statements
Use thetracing or log crates for structured logging:
Logging Configuration
RUST_LOG Environment Variable
Control logging levels and filters usingRUST_LOG. See the env_logger documentation for details.
Query Engine Specific Logging
The.envrc file configures query engine logging:
Query Graph Visualization
Enable query graph rendering to visualize query execution plans:Debugging Query Compiler
Query Compiler Playground
Use the playground to generate and visualize query plans:- Compiles Prisma queries to execution plans
- Generates query graphs
- Outputs visualization files (when Graphviz is available)
Trace Query Compilation
Profile Query Performance
Debugging Tests
Run Tests with Output
By default, tests capture output. Use--nocapture to see logs:
Test-specific Logging
CombineRUST_LOG with test execution:
Single-threaded Test Execution
Run tests sequentially to avoid interleaved output:Debug Specific Relation Test
Debugging Schema Engine
Migration Debugging
Enable detailed migration logs:Introspection Debugging
Debugging Driver Adapters
Enable Driver Adapter Logging
Debug Adapter Configuration
Print adapter configuration:Inspect Test Executor
Run the test executor directly:Debugging Build Issues
Verbose Cargo Build
Check Dependencies
Clean and Rebuild
Check Feature Flags
Debugging Wasm Builds
Wasm Build Logs
Verify Wasm Output
Common Debugging Scenarios
Investigating Test Failures
Tracing Query Execution
Debugging Connection Issues
Debugging Type Errors
Usecargo check for faster feedback:
Performance Debugging
Profiling with perf (Linux)
Flamegraph Generation
Memory Debugging with Valgrind
IDE Integration
Visual Studio Code
Recommended extensions:- rust-analyzer
- CodeLLDB (for debugging)
- Error Lens (inline errors)
.vscode/launch.json):
Rust-analyzer Settings
Prevent build lock conflicts:settings.json
Useful Environment Variables Reference
| Variable | Purpose |
|---|---|
RUST_LOG | Control log levels and filters |
RUST_LOG_FORMAT | Log format (devel, json) |
QE_LOG_LEVEL | Query engine log level |
LOG_LEVEL | General log level |
FMT_SQL | Format SQL in logs (set to 1) |
PRISMA_RENDER_DOT_FILE | Render query graphs to .dot files |
RENDER_DOT_TO_PNG | Convert .dot files to PNG (requires Graphviz) |
RUST_BACKTRACE | Show backtrace on panic (1 or full) |
UPDATE_EXPECT | Update expect! snapshots (set to 1) |
SIMPLE_TEST_MODE | Reduce relation test count |
RELATION_TEST_IDX | Run specific relation test |
Next Steps
- Review contribution guidelines
- Learn about building the engines
- Explore testing strategies