Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Updates to work with client in tc-tools #8

Merged
merged 7 commits into from Jul 18, 2018

Conversation

ydidwania
Copy link
Contributor

  1. Attempting to set up a connection using EventSource in the browser throws an error in the console:
    Request header field Cache-Control is not allowed by Access-Control-Allow-Headers in preflight response..
    Thus tc-lib-api was updated to v12.3.0 to add Cache-Control to Access-Control-Allow-Headers

  2. Also I removed

test: 
  pulse:
    fake:   true

from config.yml to allow me to run the server on localhost with real pulse creds in user-config.yml

@ydidwania ydidwania changed the title Updates to work with client in tcc-tools Updates to work with client in tc-tools Jul 13, 2018
src/api.js Outdated
@@ -88,16 +93,21 @@ builder.declare({
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Access-Control-Allow-Origin': '*',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this line? taskcluster-lib-api seems to set this header here.

src/api.js Outdated

listener.resume().then(() => {
sendEvent('ready');
idleTimeout = setTimeout(() => abort(idleMessage), 20*1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L114 seems to be creating a similar timeout. Could we have those places call createIdleTimeout instead to remove duplication? Also this will ensure we don't forget to clear the timeout before creating a new one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Also I was thinking of increasing the timeout to 120seconds. 20s seems too short to me now.

src/api.js Outdated
@@ -139,6 +149,10 @@ builder.declare({
sendEvent('error', errorMessage);
} finally {

if (idleTimeout) {
clearInterval(idleTimeout);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be clearTimeout.

@ydidwania ydidwania requested a review from imbstack July 16, 2018 17:16
Copy link
Contributor

@imbstack imbstack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also address the changes @helfi92 mentioned. Looks good otherwise.

@@ -36,6 +36,3 @@ test:

server:
port: 12345

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not permanently remove this. Just remove it locally when you want to rest for real.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/helper.js injects fake : true anyway, so I thought we shouldn't be needing this here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great. Then I retract my statement.

src/api.js Outdated
@@ -15,6 +15,9 @@ let builder = new APIBuilder({
serviceName: 'events',
version: 'v1',
context: ['listeners'],
errorCodes: {
NoReconnects: 204, // Not supporting automatic reconnects from EventSource
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Remove extra white space between the column and 204.

@imbstack imbstack merged commit f424561 into taskcluster:port-to-sse Jul 18, 2018
@imbstack imbstack temporarily deployed to taskcluster-events-staging July 20, 2018 13:46 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants