日本語

How to View SSE Messages in Chrome DevTools

​​Chrome DevTools​EventSource,fetch,Server-Sent Events

In the Network panel of Chrome DevTools, you can view Server-Sent Events (SSE) messages one by one in a table on the EventStream tab. This is useful on a screen that receives notifications or chat replies bit by bit, when you want to compare what the page shows with what the server actually sent. In my test environment, I set up a server that sends messages with event and id fields, and checked what appears on the EventStream tab and how.

Note

The test environment was Ubuntu 24.04, Node.js 22, and Chrome for Testing 153.0.8010.12. I launched a headed Chrome on a virtual display and operated the DevTools docked on the right side of the window by sending mouse and keyboard input. (Only typing Japanese text was sent through Chrome's remote debugging.) I set DevTools to English, so the tabs and buttons are written with their English labels. Times are from the clock of the test environment. I did not test macOS or Windows Chrome, SSE read with XHR, delivery over HTTP/2, or opening DevTools after the connection had already started.

The server and page used for testing

The server is written with Node.js's http module and returns SSE at http://localhost:8080/events. It sends the next message every 0.8 seconds and finally closes the response. The messages mix a line containing only retry, a comment line starting with :, a message without event, a message with event, and a message whose data spans two lines.

text
$ curl -sN -i http://localhost:8080/events
HTTP/1.1 200 OK
Content-Type: text/event-stream
Cache-Control: no-cache
Date: Sat, 21 Nov 2026 22:13:13 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

retry: 2000

id: 1
data: {"label":"在庫あり:3点"}

: keepalive

id: 2
event: price
data: {"yen":1200}

id: 3
event: notice
data: 1行目
data: 2行目

id: 4
data: {"label":"在庫あり:2点"}

After the response is closed, when the browser reconnects with a Last-Event-ID header, the server sends only one message, id: 5, and keeps the connection open.

The page connects to /events with EventSource and adds each received message to a list.

js
const es = new EventSource('/events');
es.onmessage = (e) => log(`message(id ${e.lastEventId}): ${e.data}`);
es.addEventListener('price', (e) => log(`price(id ${e.lastEventId}): ${e.data}`));
es.addEventListener('notice', (e) => log(`notice(id ${e.lastEventId}): ${e.data}`));
es.onerror = () => log(`error(readyState ${es.readyState})`);

log is a function that appends one <li> to an <ol>.

Opening the EventStream tab in the Network panel

The official documentation section on inspecting events in a stream says to record the page that streams events in the Network panel, select the request, and open the EventStream tab.

With the DevTools Network panel open, I reloaded the page. The list shows the localhost page itself and the SSE request events. The Type of events was eventsource.

The Network panel list. localhost has Type document; events has Status 200, Type eventsource, Initiator (index):38, Size 0.2 kB, Time 804 ms
Network panel list about one second after the reload

Clicking the events row shows the tabs Headers, EventStream, Response, Initiator, and Timing on the right. Opening the EventStream tab showed the received messages as a table.

The table on the EventStream tab. The columns ID, Type, Data, and Time contain four rows: 1 message, 2 price, 3 notice, 4 message. The Data of row 3 is "1st line 2nd line"
EventStream tab of events

The contents of the table, written out as text, are as follows.

ID Type Data Time
1 message {"label":"在庫あり:3点"} 22:13:26.796
2 price {"yen":1200} 22:13:28.397
3 notice 1st line 2nd line 22:13:29.198
4 message {"label":"在庫あり:2点"} 22:13:29.999

From the table, I could see the following.

  • The Type column shows the name given in the event line. A message without event was shown as message. The MDN page on SSE also says that a message without event is received by onmessage.
  • A message whose data spans two lines was shown on one line in the table, as "1st line 2nd line". It looks like one line on screen, but when I inspected the cell's text, the break between the two lines was a newline, the same as e.data on the page.
  • The line retry: 2000 alone and the : keepalive comment do not appear in the table.
  • Time shows the moment the message arrived, down to milliseconds.

The table gains a row each time a message arrives. I opened the EventStream tab right after the reload and counted the rows every 0.7 seconds: at 22:13:30.014 there were 3, and at 22:13:30.717 there were 4. The Time of the fourth row is 22:13:29.999.

Clicking a row only turns its background blue; no detailed view opened in another area.

Filtering to show only specific messages

If you enter a regular expression in the "Filter using regex" field above the EventStream table, only the matching rows remain. The official documentation also says you can filter with a regular expression. In my test, filtering produced the following results.

Text entered Remaining row IDs
price 2
yen 2
在庫 (the Japanese word for "stock") 1, 4
^\{"label" 1, 4
The filter field contains the Japanese word for "stock", and only the message rows with ID 1 and 4 remain in the table
Filter with the Japanese word for stock entered

price is not contained in the Data of ID 2 ({"yen":1200}), but the row with ID 2 remained. The text in the Type column is also a filter target. ^\{"label", which anchors to the start, kept only the rows whose Data begins with that text. Entering the alternation 2点|2行目 kept IDs 3 and 4. Clearing the field returned all four rows.

After reconnecting, the Network list gains a row

When the server closes the response, EventSource reconnects after the 2000 milliseconds given by retry. In the test, the server closed the response at about 22:13:30, and ID 5 arrived after reconnecting at 22:13:32.302. MDN also says that retry is the reconnection wait time in milliseconds. In the test, the page list showed "error (readyState 0)", followed by "notice (id 5): reconnected (last ID before was 4)".

The Network list gains one more events row. The EventStream tab of the second events showed only one row, ID 5, which arrived after reconnecting. The table of the first events still shows IDs 1 to 4. Each connection is recorded as a separate request.

Opening the Headers tab of the second events showed Last-Event-Id: 4 in Request headers. Here you can confirm that the browser tells the server the last ID it received.

The Headers tab of the second events request. Request headers list Accept: text/event-stream, Cache-Control: no-cache, Last-Event-Id: 4, and others
Request headers of the reconnecting request

The server log also showed Last-Event-ID: 4 in the second connection.

text
[server] GET /events  接続3回目  Last-Event-ID: (なし)
[server] 接続3回目の応答を閉じた
[server] GET /events  接続4回目  Last-Event-ID: 4

(The first and second connections were curl and the page load when Chrome was started.)

The Response tab shows every line that arrived

Opening the Response tab of the same events request showed the text the server sent exactly as it was, including the retry: 2000 and : keepalive lines. Lines that do not appear on the EventStream tab can be seen here.

However, in the test environment, the Japanese text was garbled.

The Response tab. The lines retry: 2000, id: 1, and data: are shown, but the Japanese label of the first message appears as garbled text like "在庫"
Response tab of events. The Japanese text is garbled

I also set the server's Content-Type to text/event-stream; charset=utf-8 and connected by running es2 = new EventSource('/events?charset=utf-8') in the Console. The Japanese on the Response tab was garbled in the same way. The display on the EventStream tab was correct Japanese in both cases. Without the charset parameter, the page display was also correct Japanese. MDN says that event streams are to be sent as UTF-8. When you want to check messages containing Japanese, look at the EventStream tab.

Streams read with fetch also appear on the EventStream tab

The official documentation says the EventStream tab shows events flowing through the Fetch API, the EventSource API, and XHR. I placed a "Read with fetch" button on the page and read the same SSE with fetch.

js
const res = await fetch('/events?via=fetch');
const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();

The Network list gained events?via=fetch, and selecting that row showed an EventStream tab as well. The four rows in the table had the same ID, Type, and Data as in the EventSource case.

The events?via=fetch request selected in the Network list, with the EventStream tab open. Four rows are shown: 1 message, 2 price, 3 notice, 4 message
EventStream tab of the request read with fetch

When reading with fetch, separating the messages is the job of the page's code. Even so, DevTools read the event and id lines and put them in the table. You can use this table to check whether the page's code splits the messages correctly.

Clearing the table

Pressing the circle-with-a-slash button at the top left of the EventStream tab (Clear all appears when you hover over it) emptied the table. The official documentation says that Clear removes the list of recorded events. Even after selecting another request and coming back, the table stayed empty. If you clear the table of a connection that has already ended, the messages of that request can no longer be viewed on the EventStream tab.

​Posted by 86