28

I have an EventSource listener on my frontend calling a complicated backend scheme. This code block is written in Typescript.

import * as EventSource from 'eventsource';      

private streamData() {
    let source = new EventSource('http://localhost:3000/websocket/server/stream');

    source.onopen = (e) => {

    };

    source.onmessage = (e) => {
      console.log('id: ' + (<any>e).lastEventId + '; type: ' + e.type + ' data: ' + e.data);
    };
  }

And I send back the following response to my server :

res.write('id: ' + this.messageId++ + '\n');
res.write('type: message\n');
res.write('data: ' + message + '\n\n');
res.flush();

Now, on the Chrome console, I get all the data needed. enter image description here

However, on the xhr monitor, I cannot see the EventStream data.

enter image description here

I get the info on my frontend, so this is not a blocking issue for me, but may pose some problems later in debugging.

scharette
  • 9,437
  • 8
  • 33
  • 67
plavz
  • 281
  • 1
  • 3
  • 4

3 Answers3

19

I had the same issue. The data does not show up when you are using the eventsource polyfill only when you use the built in browser implementation of the EventSource class.

Jeff Hall
  • 191
  • 1
  • 4
  • 1
    This is actually correct, when I switch to political chrome stopped showing the messages – Medin Jul 10 '21 at 22:59
0

This doesn't answer the question but is related to if you search for "Event Stream data not showing in Chrome console"

In Chrome devtools Network tab, an eventsource type request will not show an EventStream tab until you receive a first event from the server.

So you might just have to be patient.

icc97
  • 11,395
  • 8
  • 76
  • 90
0

unfortunately, this problem is relevant for all non native SSE clients. https://github.com/Azure/fetch-event-source/issues/3

Consider using window.EventSource if it fits your use case.

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – ethry Aug 26 '23 at 22:01