Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event Stream data not showing in Chrome console

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.

like image 743
plavz Avatar asked Mar 16 '19 20:03

plavz


People also ask

How do I enable console debugging in Chrome?

Click the Console tab. Press Control + [ or Command + [ (Mac) until the Console is in focus. Open the Command Menu, start typing Console , select the Show Console Panel command, and then press Enter .

How do I see post payload in Chrome?

To view the request or response HTTP headers in Google Chrome, take the following steps : In Chrome, visit a URL, right click , select Inspect to open the developer tools. Select Network tab. Reload the page, select any HTTP request on the left panel, and the HTTP headers will be displayed on the right panel.

What is VM in Chrome console?

It is abbreviation of the phrase Virtual Machine. In the Chrome JavaScript engine (called V8) each script has its own script ID. Sometimes V8 has no information about the file name of a script, for example in the case of an eval .


1 Answers

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.

like image 170
Jeff Hall Avatar answered Sep 22 '22 13:09

Jeff Hall