Naite Viewer Overview
Real-time Visualization
During test executionImmediate log display
Unix Socket Communication
Inter-process communicationFast transmission
Project Isolation
Separate socket filesIndependent operation
Auto Connection
On Extension startupAutomatic socket creation
What is Naite Viewer?
Naite Viewer is a feature included in the Sonamu VSCode Extension that visualizes Naite logs recorded during test execution in real-time. Naite transmits all data recorded withNaite.t() during test execution to the VSCode Extension, allowing developers to visually track test flows. This is especially useful for complex business logic or situations involving multiple intertwined function calls.
Key Features
1
Real-time Log Display
Immediately displays all logs recorded with
Naite.t() during test execution in the VSCode panel. View structured logs without searching through the console.2
Grouping by Test
Automatically groups logs by test case. Also categorized by Suite, so you can quickly find desired
logs even in large-scale tests.
3
Callstack Tracking
Displays the call location and full callstack information for each log. Click on a log to navigate
directly to that code location.
4
Filtering and Search
Filter logs from specific modules using wildcard patterns (
user:*), or search log contents by keyword.Architecture
1. Unix Socket Communication
Naite Viewer communicates with the test process through Unix Socket. This method allows direct inter-process communication without using the file system, making it fast and secure. Benefits of socket communication:- Fast transmission: Much faster IPC (Inter-Process Communication) than HTTP or files
- Real-time: Logs are delivered to Extension immediately as tests run
- Isolation: Independent sockets per project prevent conflicts
- macOS / Linux
- Windows
{hash} is the first 8 characters of the MD5 hash of the sonamu.config.ts path.See Hash Generation Method in Detail
See Hash Generation Method in Detail
Each project generates a unique hash based on the absolute path of the This way, even when running multiple Sonamu projects simultaneously, each uses an independent socket so logs donβt get mixed.
sonamu.config.ts file:2. Message Protocol
Three types of messages are transmitted between the test process and Extension.run/start - Test Run Start
Sent when a test run starts. The Extension clears all existing logs and prepares for a new test run upon receiving this message.In watch mode, when you modify a file, tests are re-run, and a
run/start message is sent each
time, reinitializing the Viewer.test/result - Test Result
Sent each time a test case completes. Includes the test result along with Naite logs (traces).- Test metadata: Suite name, file path, line number
- Test result: Pass/fail status, duration, error info
- Naite traces: All logs recorded with
Naite.t()
run/end - Test Run End
Sent when all tests complete. The Extension recognizes the test run has ended with this message.3. Transmission Flow
Letβs look at the order in which messages are sent throughout the test execution process.Transmission Flow in Code
Transmission Flow in Code
Installation and Setup
1. Extension Installation
1
Install from VSCode Marketplace
- Click the Extensions icon in VSCodeβs left sidebar
- Search for βSonamuβ
- Click the Install button
2
Verify Extension Activation
After installation, if the Sonamu icon appears in VSCodeβs bottom status bar, itβs properly activated.
2. Auto Connection
The Extension automatically starts the socket server when it runs:1
Project Detection
Finds the
sonamu.config.ts file in the current workspace.2
Hash Calculation
Generates an MD5 hash (first 8 characters) from the absolute path of
sonamu.config.ts.3
Socket Server Start
Starts a Unix Socket server at
~/.sonamu/naite-{hash}.sock.4
Wait for Test Process
NaiteReporter connects to this socket when tests run.
The Extension creates sockets based on project path, so you must open the project folder
directly for it to work properly. Opening a parent folder may result in different socket paths
that donβt connect.
3. Running Tests
- Regular Execution
- Watch Mode
- Specific File
Usage
1. Opening the Naite Viewer Panel
- Command Palette
- Keyboard Shortcut
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux)- Type βNaite: Open Viewerβ
- Enter
2. Viewing Logs
Logs automatically appear in Naite Viewer when tests run.Viewer Screen Layout
Naite Viewer displays tests in a 3-level hierarchy:- Hierarchy Structure
- Actual Screen
- Structure Explanation
Real-time Updates: In watch mode, when you modify a file, tests auto-rerun and the Viewer
updates immediately. This lets you see the impact of code changes right away.
3. Checking Callstack
Click on a log to see detailed information about thatNaite.t() call.
Callstack Information Example
Callstack Information Example
test(line 20): Location whereNaite.t()was called in test codecreateUser(line 45): Actual business logic called by testrunWithMockContext: Sonamuβs Context wrapper (displayed up to here)
4. Filtering and Search
In large-scale tests, hundreds of logs can be generated. Use filtering to quickly find desired logs.- Key Pattern Filter
- Text Search
- Status Filter
Show only logs from specific modules with wildcard patterns:Filtering happens in real-time as you type patterns in the input field.
Practical Use Cases
1. Debugging Complex Business Logic
When debugging complex logic that goes through multiple steps, you can track the state at each step.Viewing in Viewer
Viewing in Viewer
In the Viewer, it displays like this:If payment step failed:
- Logs only up to
order:payment:start - Clearly identify which step succeeded
- Use callstack to confirm exact failure location
order:payment:*β Show only payment-related logsorder:*:startβ Show only start logs for all steps
2. Syncer Code Generation Tracking
Track which templates Sonamuβs Syncer rendered and which files it created.Syncer Log Example
Syncer Log Example
Viewer shows all operations performed by Syncer:Analysis:
- See order of file creation
- Measure each template rendering time
- Filter and check specific templates (
syncer:renderTemplate:*)
3. API Call Chain Tracking
When calling multiple APIs in sequence, track inputs and outputs of each API.4. Identifying Performance Bottlenecks
Find sections that take long and optimize them.Performance Analysis
Performance Analysis
Comparing timestamps for each step in Viewer:Analysis result:
processDatatakes longest at 3.3 seconds (bottleneck)fetchLargeDatais acceptable at 1.5 secondssaveToDatabaseis fast at 0.4 seconds
processData5. Error Cause Tracking
Track which step and what data caused an error.Importance of Callstack for Errors: The Viewerβs callstack info shows the exact code line
where the error occurred. This is especially useful for complex call chains that are hard to
figure out with
console.log.Understanding Internal Structure
NaiteReporter Connection Management
NaiteReporter includes buffering and reconnection logic for stable socket connection management.Full NaiteReporter Structure
Full NaiteReporter Structure
- Buffering: Stores messages in buffer even if Extension isnβt ready (keeps the most recent 1,000 messages)
- Lazy connection: Connection failure is not treated as error
- Auto resend: Sends all buffered messages on successful connection
- CI detection: Skips socket communication in CI environment
Per-Project Socket Isolation
Isolate logs when working on multiple Sonamu projects simultaneously.- Hash Generation
- Socket Path
- Result
- Complete isolation of logs between projects
- Simultaneous execution support (test A while testing B)
- Stable operation without conflicts
Integration with bootstrap.ts
Sonamuβs test bootstrap callsNaite.getAllTraces() for each test to collect logs.
Naite Integration in bootstrap.ts
Naite Integration in bootstrap.ts
- test() wrapper: Wraps Vitestβs
test()to auto-collect traces - Both try-catch branches: Collects traces on both success/failure for error debugging
- task.meta usage: Uses Vitestβs metadata system to pass traces
- afterEach send: Sends to Reporter after each test ends
Troubleshooting
Extension Not Receiving Logs
Extension Not Running
Extension Not Running
Symptoms:
- No Sonamu icon in VSCode bottom status bar
- Canβt open Naite Viewer panel
- Check Sonamu Extension in Extensions tab
- Click βEnableβ or βReloadβ button
- Restart VSCode:
Cmd+Shift+Pβ βReload Windowβ
Socket Path Mismatch
Socket Path Mismatch
Symptoms:
- Extension is running
- Tests succeed but logs donβt appear
- βENOENTβ or βECONNREFUSEDβ error in console
- Open project folder directly in VSCode
- Restart Extension
Socket File Permission Issue
Socket File Permission Issue
Symptoms:
- βPermission deniedβ error
- Socket file exists but canβt access
Too Many Logs Causing Slowdown
- Bad Example
- Good Example
- Conditional Logging
Socket Connection Error in CI Environment
Auto Disable: NaiteReporter automatically detects CI environment and skips socket
communication.
process.env.CI === "true"- Automatically set in GitHub Actions, GitLab CI, CircleCI, etc.
Logs Accumulating in Watch Mode
When modifying files multiple times in watch mode, previous test logs may remain. Manual clear methods:- Click βClear Allβ button at top of Naite Viewer panel
- Or Command Palette β βNaite: Clear Logsβ
Cautions
Next Steps
Debugging Tests
Identify error causes with callstack tracking
Querying Logs
Query logs with Naite.get()
Recording Logs
Detailed Naite.t() usage
What is Naite?
Naite overview