Skip to content

Commit a86d08a

Browse files
committed
commiting before checking out master branch
1 parent e969876 commit a86d08a

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

SSEController.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ SSEController.createStream = (reqResObj, options, event) => {
1313
// because EventSource cannot access headers, we are making a regular get request to SSE server to get its headers, and then passing those headers into function where we will be connecting our EventSource, there will a time delay between the time the user opens the request and the server sends back its first response. We keep reference to the time the first request was made to account for that time difference later on.
1414
const startTime = Date.now();
1515

16-
http.get(headers.url, {
16+
const req = http.get(headers.url, {
1717
headers,
1818
agent: false,
19-
}, (res) => {
20-
// update info in reqResObj to reflect fact that connection was succesful
21-
reqResObj.response.headers = {...res.headers};
22-
reqResObj.connection = 'open';
23-
reqResObj.connectionType = 'SSE';
24-
// invoke function that will create an EventSource
25-
SSEController.readStream(reqResObj, event, Date.now() - startTime);
19+
});
20+
req.once('response', (res) => {
21+
console.log('wrong thing got response, budy1')
22+
// update info in reqResObj to reflect fact that connection was succesful
23+
reqResObj.response.headers = {...res.headers};
24+
reqResObj.connection = 'open';
25+
reqResObj.connectionType = 'SSE';
26+
// invoke function that will create an EventSource
27+
SSEController.readStream(reqResObj, event, Date.now() - startTime);
28+
req.destroy();
2629
});
2730
};
2831

@@ -43,8 +46,9 @@ SSEController.readStream = (reqResObj, event, timeDiff) => {
4346
return event.sender.send('reqResUpdate', reqResObj);
4447
};
4548
sse.onerror = (err) => {
46-
console.log('there was an error in SSEController.readStream', err)
47-
};
49+
console.log('there was an error in SSEController.readStream', err);
50+
see.close();
51+
};
4852
};
4953

5054
module.exports = SSEController;

src/client/controllers/reqResController.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as actions from "../actions/actions";
66
// import grpcController from "./grpcController.js";
77

88
const { api } = window;
9-
let events;
9+
1010
const connectionController = {
1111
openConnectionArray: [],
1212
// selectedArray:[],
@@ -94,7 +94,8 @@ const connectionController = {
9494
const foundAbortController = this.openConnectionArray.find(
9595
(obj) => obj.id === id
9696
);
97-
97+
98+
console.log('open connection array is : ', this.openConnectionArray)
9899
if (foundAbortController) {
99100
switch (foundAbortController.protocol) {
100101
case "HTTP1": {

test/fakeSEEServer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const sendSSEs = (response, id = 0, timeout) => {
2020
`id: ${id}\ndata: This is event ${id}\n\n`
2121
);
2222
id++;
23+
console.log('just sent something else! ')
2324

2425
if (id < 6) {
2526
timeout = setTimeout(() => {

0 commit comments

Comments
 (0)