The debug viewer
The debug viewer is a page in your browser. It shows the requests that your server recorded. For each
request, you see its status, its duration, its queries and its log lines. You also see the values it
dumped: the values it printed for debugging with Core\Debug::dump. Other pages show
totals for each route and for each query.
nvs debug serves the viewer. It also reads the recorded requests into one database,
debug/index.sqlite in the data folder. This is a SQLite database, which is one file.
Start the viewer
Section titled “Start the viewer”Turn on recording in nvs.toml:
[debug]store = trueThen start your server with nvs serve in development mode. nvs serve starts nvs debug for you, and stops it when the
server stops. With this setting, nvs run and nvs test are recorded too.
nvs debug prints a link to the viewer. Open the viewer with this link. The link contains a token,
which is a long random text. The viewer opens only in a browser that has the token. Another user
account on the same computer does not have it.
nvs debug link prints the same link again, and it starts nothing:
nvs debug linkWith --json, it prints one JSON object with four fields:
url: the link to the viewer.embed: the link that an editor shows inside its own window.running:truewhennvs debugruns.recording:truewhen[debug] storeis on.
The address is 127.0.0.1:8137. [debug] listen or the --listen option sets another address.
A production server never starts nvs debug. On a production host, you run nvs debug yourself.
Then it shows the requests that the production server recorded.
A production server records less, because a request can contain a customer’s data:
- A request keeps its status, its duration and its events, such as its queries.
- A request keeps no header and no body, of the request or of the response. So its Request and Response tabs show no header and no body.
- A dump keeps its file and line, and the type and size of each value. It keeps no value. The
viewer shows Not recorded in production mode. To see a value in production, write it with
Core\Log.
The viewer’s window
Section titled “The viewer’s window”A list on the left names the pages: Requests, Runs, Routes, Queries, Outbound, Code, Errors, Logs, Debug, Mail, Schedule and Stream. Settings is at the bottom of this list. Errors shows a number. It is the number of exceptions that were thrown after you opened the viewer. Debug shows the number of dumps, profiles and traces that were recorded after you opened the viewer. In a narrow window, the list shows only its icons.
The Stream page lists every record of every kind in one list, newest first. A dump’s row shows its value on one line after the file and line of the dump. Click the row to see the whole value below the list.
The bar at the top has the search box, the live state and the theme button. The live state shows
the text Live when nvs serve started nvs debug. It shows Recording stopped when nvs debug runs
without a server. The theme button changes between the system’s theme, dark and light.
Press Ctrl+K (Cmd+K on macOS) to open a list of every page and action. Type a few letters to
find one. Press ? to see every key.
Every file:line in the viewer is a link. It opens the file in your editor. Choose the editor on
the Settings page. In VS Code, the Novis extension can show the viewer in an editor tab. Read
The debug viewer in the editor.
The request list
Section titled “The request list”The first page lists the requests, newest first. Each row has the method, the route, the status,
the duration, the number of queries and dumps, and the exception the request threw. A dump is a
value that the request printed with Core\Debug::dump. The route is the path of its
#[Core\Route], such as /notes/{id}.

A bar in each row shows how the request’s time was split. Each colour is one kind of work: queries,
HTTP calls, the cache, the session, files, garbage collection and processes. Garbage collection is
the time Novis spends to free memory that the program no longer uses. The gray part of the bar shows
the time that your own code ran. A badge such as 5× means that one query ran five times at the
same line of your code.
The filters above the list choose the method, the status, the route, a minimum duration, and
whether the request threw an exception. The Refused filter is described below. A status filter can be one code, such as 404, or a class,
such as 5xx. The filters are part of the page’s link. Press s to save the filters under a name.
The server checks each request. When a request does not pass a check, the server answers with an error, and the viewer marks the request as refused. Its row shows the cause after its path, such as Refused: CSRF check. The Refused filter shows every refused request, or only the requests with one cause.
| Cause | What happened |
|---|---|
| CSRF check | a form was sent without a valid CSRF token. This token is a secret value that shows the form came from your own site |
| CORS origin | a script on another website tried to call your server, and your CORS settings do not allow that website |
| body too large | the request body was larger than its limit |
| no mount | no app answers this path |
| unknown host | the Host header names a host that the server does not serve |
| server busy | the server had too many requests or connections open |
| unknown method | the method is not one of the eight HTTP methods |
| malformed request | the server could not read the request |
| capability not granted | your code tried to do something that [capabilities] does not allow, and did not catch the error |
Three boxes above the list show the last five minutes. They show the number of requests, the median duration (p50) and the share of requests that failed. The median is the middle value: half of the requests were faster, and half were slower.
New rows appear at the top while you watch. To pause the list, press p or scroll down. While
it is paused, the rows on the page do not move. A number shows how many new rows arrived.
Press j and k to move the selection. A panel beside the list shows the selected request’s
events. Press Enter to open the request.
A request’s page
Section titled “A request’s page”When you open a request, you see its method, path, status, duration and route. You also see its trace id and span id. The trace id is a unique id that Novis gives each request. The span id is the id of this request’s own part of the work.
You also see the handler: the method in your code that the route called. Boxes show the duration and the number of queries, dumps and log lines. Below them, a bar shows how the time was split.
Two more boxes show the memory and the sizes. Memory peak is the most memory the request used.
Beside it is the memory limit, which [limits] memory in nvs.toml sets. The bar under the
memory peak turns orange at 75% of the limit, and red at 90%.
Response size is the number of bytes in the response body. It also shows how many bytes of the request body your program read. A streamed response is sent in parts while your program runs. The viewer shows no size for it.
The tabs below show one part of the request each. The tab is part of the page’s link, such as
?tab=queries.
| Tab | What it shows |
|---|---|
| Timeline | every event of the request on one time axis: queries, HTTP calls, cache, files, processes and dumps |
| Request | the method, the path, the query, the headers and the body that your server received |
| Response | the status, the headers and the body that your server sent |
| Queries | each query, grouped by the line that ran it, with how often it ran there |
| Cache | each cache key, with its calls, hits and misses |
| Dumps | each value that Core\Debug::dump wrote |
| Logs | the request’s log lines |
| Coverage | which lines of your code ran, when the server ran with [debug] mode = ["coverage"] |
| Exception | the exception and its stack, when the request threw one |
Each event on the timeline shows its result after its name:
- A cache read shows Hit or Miss, and the store:
memoryorredis. - An HTTP call shows its status code and the bytes it sent and received.
- A file read or write shows its number of bytes.
- A process shows the name of its program and its exit code.
- Sent mail shows the number of recipients. The timeline shows no address and no text.
- A job pushed to the queue shows its script, its queue and its delay.
- A call to LDAP, IMAP, a file transfer server or Redis shows the server it reached.
- A database transaction and a schema apply show the
[db.<name>]block they used. - A call that failed shows the class of the error it threw.
- A fault is an error inside Novis (a panic), a limit that stopped the request, or a TLS
connection that failed. The limits are
[limits] memory,cpu_time,wall_timeandmax_output. The fault shows its cause and its message.
A request that opened a WebSocket or an event stream shows the connection under its timeline. You see when it opened, how long it was open, and how many frames went each way. A frame is one message of the connection. You also see why it closed, for example because the client closed it. In development, the first 32 frames each way are shown, each cut to 1 KB.
The Exception tab shows the stack: every function that was running when the exception was
thrown, the innermost first. The functions of your own code are in bold text. The functions of
Core are in gray text. An exception can have a previous exception: the exception that caused
it. The tab shows the previous exception below the first one, with its own stack. The stack never
contains the values of arguments, because a value can be a secret.

The Request and Response tabs show the headers as a table. A JSON body is shown as a tree, and any other body as text. An HTML body is shown as text too, so it never runs in the viewer.
A request body can contain a password. So in a JSON or form body, the value of a field named
password, passwd, secret, token, api_key or apikey is replaced with [redacted]. Upper
and lower case do not matter. A note under the body lists the fields that were replaced. Any other
body is saved as it was sent. Its note says Not checked for passwords.

Copy as curl copies a curl command that sends the same request. Some headers, such as
Authorization, contain a password or a key. When a request is recorded, the value of such a
header is replaced with [redacted]. The command contains this text too.
From your page to the viewer
Section titled “From your page to the viewer”In development, [debug] inline adds the output of Core\Debug::dump to the end of an HTML page.
When [debug] store is also on, this output starts with one more line. It shows how many queries
the request ran, and it has a link. The link opens this request in the viewer.
The Runs page lists work that is not a request, newest first:
- a job of a
[[schedule]]block innvs.toml, - a job that a worker took from the queue,
- a run of
nvs runornvs test.
Each row shows the kind, the name, the outcome, the duration, the memory peak, and the number of queries and dumps. The outcome is OK, Failed or Cancelled. A run that threw an exception shows its class and the line that threw it. The filters above the list choose the kind, the outcome, a minimum duration and a minimum memory peak.

Press Enter to open a run. A run’s page has the same boxes and tabs as a request’s page. It has no
Request and Response tabs, because a run has no HTTP request. The Timeline tab also
lists the profiles the run wrote, and the lines where a value was copied. A run has three more tabs,
and each one shows only when the run has something for it:
| Tab | What it shows |
|---|---|
| Tests | each test that nvs test ran, with Passed, Failed, Skipped or Flaky, its duration and its file and line. A failed test shows its failure message. A flaky test failed and then passed when it ran again |
| Output | what nvs run or nvs test printed in the terminal, in development mode. The viewer keeps the last 64 KB |
| Coverage | which lines of your code ran, when the run had [debug] mode = ["coverage"] |
nvs debug deletes the oldest records of a long run first. When it has deleted records of a run,
the page of the run says so. It gives a time, and says that the records before that time were
deleted.

The Mail page lists the mail of each [mail.<name>] block with capture = true. Such a block
keeps each message and sends nothing. The page needs [debug] store = true. A block that really
sends mail is not on this page.
Open a message to see its headers, its text and its attachments. The HTML is shown in two forms. As written is the HTML your program wrote. As sent is the HTML after its CSS is copied into the elements. Scripts do not run in this preview, and nothing loads from the network.
The page also lists the CSS rules that stay in a <style> element, and the rules that match no
element. A note appears when the HTML is larger than 102 KB, because Gmail cuts such a message.
Routes
Section titled “Routes”The Routes page has one row for each method and route. Each row shows the number of requests and the number of errors. It also shows two durations, p50 and p95. Half of the route’s requests were faster than p50. 95 of every 100 requests were faster than p95, so p95 shows the slow requests. The row also shows the average number of queries, and when the route last ran.
Click a column’s name to sort by it. Click a row to see the route’s requests.

Queries
Section titled “Queries”The Queries page has one row for each line of your code that ran a query. Each row shows the
query, how often it ran, its total and its longest time, and how many requests ran it. A badge
such as 3× shows that one request ran the query three times at that line. Such a query is often
inside a loop. One query that reads all the rows can often replace it.

Search
Section titled “Search”The search box searches the requests, the dumps, the log lines, the queries, the exceptions and the
outbound calls. Press / to go to the search box. The results are grouped by request, newest first.
A word such as status:500 searches one field. refused:csrf finds the requests refused for one
cause, and refused:any finds every refused request. kind:ldap finds the requests that made an
LDAP call, and target:api.example.com finds the calls to that server.

Press s to save a search as a filter. You can also paste a trace id into the search box. Each
response from your server has a traceresponse header, which contains the request’s trace id. You
can paste the value of this header too. The viewer then opens that request.
Errors
Section titled “Errors”The Errors page has two tabs. The Exceptions tab has one row for each exception class and the line that threw it. Each row has a count, and the dates when the exception was first and last seen.

Here, three requests were for an invoice that does not exist. Each one threw the same
RuntimeError on the same line. The page shows them as one row with the count 3.
The Faults tab lists the faults, newest first. A fault is an error inside Novis (a panic), a
limit that stopped a request or a run, or a TLS connection that failed. Each row shows the cause,
the message and a link to the request or run. You can show one cause only, such as memory_limit.
The Logs page lists the log lines, newest first. Filter them by level, by route and by
request. The Server filter shows the lines that the server wrote about itself. These are, for
example, its start, a reload, a compile error, a scheduled job that did not start, or a sign-in to
the viewer. Each such line names the part of the server that wrote it. You do not need
nvs debug --tail to see these lines.
Outbound
Section titled “Outbound”The Outbound page lists the calls that your code made to other servers. It has one row for each
kind of call and each server it reached. The kinds are HTTP, mail, the cache, the queue, LDAP,
IMAP, file transfer, Redis, database transactions and schema applies. The server is a host and
port, or the name of a block in nvs.toml, such as [mail.<name>].
Each row shows the number of calls, the failed calls, the total and the longest time, and the
number of requests. A row with a failed call has a red background, and it shows the class of the
newest error. The row with the most total time is first. Press Enter to search for the calls of a
row.
The Code page shows your code with the counts of all recorded requests and runs added up. It has two tabs.
The Coverage tab shows each file with the number of times each line ran. It needs
[debug] mode = ["coverage"].
The Copies tab lists the lines where Novis made a second copy of a value, such as a string or an
array. A copy costs time and memory. The line with the most copies is first. Each row shows why
the value was copied, and how to avoid the copy. Press Enter to open the line in your editor.
Schedule
Section titled “Schedule”The Schedule page shows the scheduler and the queues of the running server.
The first table lists each [[schedule]] block in nvs.toml. Each row shows when the job runs,
its next run, and how its last run ended: Ran, Failed or Did not start. When a job did
not start or failed, the row shows the message. The server does not schedule a job that has an
error in its block, and the row shows that error.
The second table lists each queue with its pending, due, failed and dead-letter jobs. A dead-letter job failed too many times, and the queue does not run it again. Below a queue with dead-letter jobs, the page lists the newest 20, each with the first line of its error. The server updates these counts at most once a minute.
Debug calls
Section titled “Debug calls”The Debug page lists what your code recorded with Core\Debug, from every request and every
run. A dump is a value that Core\Debug::dump wrote. A profile is a file that
Core\Debug::startProfile wrote. It shows which calls took the most time. A trace is a file that
Core\Debug::startTrace wrote. It has one line for each call.
The Newest tab lists every dump, profile and trace, newest first. New ones show at the top while the page is open. Each row shows the time, the kind, the file and line of the call, and the request or run that wrote it. A dump’s row also shows its value on one line. A profile’s or a trace’s row shows the name of its file.
Click a row to see the whole value or file below the list. For a profile, you can open the file in VS Code or download it.

You can filter the list by kind (dump, profile or trace), by file and line, by route, and by words
in the value. Write the file and line as src/Shop.nvs:12.
The By site tab has one row for each kind and each line that called Core\Debug. Each row shows
how many records the viewer has from that line, and the first and last time. A dump’s row also
shows the newest value. Click a row to see its records in the Newest tab.
Compare two requests
Section titled “Compare two requests”Press c to compare a request with the previous request to the same route. To compare any two
requests, press m to select one. The next request you open is compared with it.

The page shows the two requests side by side and highlights each row that differs. It compares the request’s path, query, headers and body. It also compares the response’s status, headers and body. Then it compares the queries, the dumps and the log lines.
Send a request again
Section titled “Send a request again”Press r to replay a request. The viewer sends the recorded request to your development server
again. Replay works only when nvs serve started nvs debug.

Your code runs again for this request. If it sends an email, the email is sent again. If it writes rows to the database, the rows are written again. So the viewer first shows a dialog. The request is sent only when you click Send.
Make a test from a request
Section titled “Make a test from a request”Press t to make a test from a request. The test sends the same request to your program with
Core\Test::request. It checks that the response is the same.

The test checks the status, the Content-Type header, the Location header of a redirect, and the
body. A JSON body is compared as data, so spaces in it do not matter. The Copy button copies the
test. Save it in your project and run it with nvs test ..
nvs debug to-test prints the same test in a terminal. Give it the trace id that the viewer shows.
--write <file> writes the test to a new file. When no recorded request has that trace id, the
command prints an error:
nvs --data data debug --oncenvs --data data debug to-test 4bf92f3577b34da6a3ce929d0e0e4736error: No request in the index has this trace id and span id.exit 1The recorded value of a header such as Authorization is replaced, as the Request tab shows. In
the test, such a header has the value 'redacted'. Replace it with a credential that your tests may use.
Debug a server
Section titled “Debug a server”The viewer on your computer can also show the records of a server, such as a production server.
The records stay on that server. Your own nvs debug reads them over an encrypted connection, and
your browser shows them as usual.
What a team commits
Section titled “What a team commits”Each developer runs nvs debug key once, on their own computer. It prints a public key:
nvs debug keyAdd that key to the server’s block in the project’s nvs.toml, with the developer’s name:
[debug.remote]listen = "0.0.0.0:7443"keys = [ { name = "alice", key = "ed25519:rxBjyDjrFNLoqWWf3+WZLG/QuiTSZo4kNQ6aCuM11RI=" },]Then run nvs debug fingerprint on the server. It prints a line such as
fingerprint = "sha256:...". A fingerprint is a short value that identifies one certificate.
The server also writes this line to its log when it starts. The log is the place that [log] target
names. In a JSON log, the record has the value in its fingerprint field. Add the server to the
list of servers, with that line:
[[debug.server]]name = "production"address = "app.example.com:7443"fingerprint = "sha256:VoWQXz34xsBarYqbTfmhv83LCHcj57oL+IOYFHMFZHU="An entry can also have a group. Servers with the same group are behind one load balancer.
Neither block contains a secret, so you can commit both. The server reads [debug.remote]. Only
nvs debug on a developer’s computer reads [[debug.server]], so one nvs.toml works for both.
A connection uses TLS 1.3. Your nvs debug sends your key, and the server checks that its
keys list contains it. A connection without a listed key ends before the server reads a
request. The server’s log names each connection by its key’s name.
Your nvs debug checks that the server’s certificate has the entry’s fingerprint. An entry
without a fingerprint is checked in the way a browser checks a website. Then the server needs a
certificate for its host name.
Two ways to reach a server
Section titled “Two ways to reach a server”The first way: your nvs debug connects to the port in listen. Open this port in the server’s
firewall for the developers’ addresses.
The second way is for a host that allows only port 443. A proxy on port 443 sends the debug
connections to listen, and every other connection to your application. The proxy needs a way to
tell them apart.
When a TLS connection starts, the client sends a list of the protocols it uses.
This list is called ALPN, and it is not encrypted. Your nvs debug sends the protocol name
nvs-debug/1. In nginx, the ssl_preread module reads it:
stream { map $ssl_preread_alpn_protocols $backend { ~\bnvs-debug/1\b 127.0.0.1:7443; default 127.0.0.1:8443; } server { listen 443; ssl_preread on; proxy_pass $backend; }}In this example, your application’s TLS server listens on port 8443. The debug service listens
on port 7443.
Some load balancers decrypt every connection. Such a load balancer cannot send a debug connection on, because the key check needs one encrypted connection from your computer to the server. In that case, open an SSH tunnel to the server:
ssh -L 7443:127.0.0.1:7443 app.example.comThen click Add a server in the viewer. Enter the address 127.0.0.1:7443 and the server’s
fingerprint.
Choose a server
Section titled “Choose a server”The left side of the viewer lists the servers. This machine is your own computer. Click a
server to see its requests, queries and logs. Add a server adds a server of your own, which
only you see. Servers that share a group are behind one load balancer. The viewer shows their
requests in one list.
Record requests for a short time
Section titled “Record requests for a short time”A production server records no headers, no body and no dumped values. You can turn on recording for a short time. This is a capture.
Open Captures, and click Record requests. Choose which requests to record. A capture can record every request, or a share of the requests. It can also record the requests of a route, a session or a header value, or of a named point in your code.
Choose what the capture keeps, and for how long. A capture can keep requests, headers,
bodies, dumps and queries. The server’s [debug.remote] allow lists which of these a
capture may keep. max_window is the longest time. The capture ends on its own at that time.
The credentials in headers and bodies are replaced with [redacted]. While a capture runs, every
developer connected to that server sees a banner. It shows who started the capture, and when it ends.
A named point is a call to Core\Debug::recordIfArmed in your code:
<?nvs// Shows a named point at the start of a checkout.
// Nobody started a capture for `checkout` here, so this returns `false`.bool $recorded = Core\Debug::recordIfArmed('checkout');
// This prints: recorded: no.echo 'recorded: ', $recorded ? 'yes' : 'no', "\n";recorded: noIt records the request only while a developer has started a capture for the point checkout.
Your code cannot start a capture.
Settings and lost records
Section titled “Settings and lost records”The Settings page has the theme, the editor that a file:line opens, and your saved filters.
Your program can run in a container. There, its files can have other paths than on your
computer, and a file:line link does not open. A path mapping fixes this. It replaces the start of each recorded
path, such as /app, with the folder on your computer. A button at the bottom deletes every
recorded request.
The Sign-ins list shows the newest 50 sign-ins to the viewer. A sign-in is each time a browser opened the viewer’s link with its token. Each row shows the time, the address and the browser.
Your server saves each request as records: one for the request, and one for each query, dump and
log line. These records wait in a folder until nvs debug reads them. The folder has a size limit,
[debug] spool_max. When the folder is full, Novis deletes the oldest files, and their records are
lost.
A record is also lost when nvs debug cannot read it. Then the live state turns orange and shows the number of
lost records. Click it to see each count on the Settings page.

Read more in Reference: nvs debug, Reference: The debug viewer, Reference: nvs debug link and Reference: nvs debug to-test.
