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:1
Install Graphviz
2
Enable Dot File Rendering
.dot files for query graphs during execution.3
Render to PNG (Optional)
For query compiler tests:This automatically converts
.dot files to PNG images.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
1
Run failing test with logs
2
Check snapshot differences
3
Inspect test database
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
Next Steps
- Review contribution guidelines
- Learn about building the engines
- Explore testing strategies