-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup websockets communication between web and workers #171
Conversation
@@ -45,6 +45,18 @@ export const runEvaluationJob = async (job: Job<RunEvaluationJobData>) => { | |||
} | |||
|
|||
await progressTracker.incrementErrors() | |||
} finally { | |||
await progressTracker.decrementTotal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decrementTotal was only in the catch but I think is something we want to do always no?
Also I think we could make decrementTotal
private and run it inside increamentErrors
and the other method for success
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm no we only wanna do it when there's an error, if we succeed we don't wanna decrement the total
apps/web/package.json
Outdated
@@ -27,10 +27,12 @@ | |||
"@sentry/nextjs": "^8", | |||
"@t3-oss/env-nextjs": "^0.10.1", | |||
"ai": "^3.2.42", | |||
"socket.io-react-hook": "^2.4.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very complicated to integrate but this package is small and nice
caced6f
to
dbaacf8
Compare
apps/web/package.json
Outdated
@@ -42,6 +43,8 @@ | |||
"nprogress": "^0.2.0", | |||
"react": "19.0.0-rc-f994737d14-20240522", | |||
"react-dom": "19.0.0-rc-f994737d14-20240522", | |||
"socket.io-client": "^4.7.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 Included in the hook
token, | ||
cookiesOptions: { | ||
secure: isProd, | ||
domain: isProd ? `.${env.APP_DOMAIN}` : 'localhost', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CORS for all the subdomains of the app domain. This way we can share cookies between web client and websockets server as auth method
61e7179
to
6921e29
Compare
7d7f57c
to
2e282eb
Compare
We want to keep the client informed when evaluations are running. How many logs are created and how many logs fail. This PR setup a new Express server that setup a Socket.IO websocket server with 2 endpoints /websocket and worker-websocket. The one for web has secure cookies token auth and the one for workers share a secret token between Sockets server and workers. I think this setup makes sense
2e282eb
to
6ece440
Compare
@@ -23,5 +24,6 @@ export default createEnv({ | |||
GATEWAY_HOSTNAME: process.env.GATEWAY_HOSTNAME, | |||
GATEWAY_PORT: process.env.GATEWAY_PORT, | |||
GATEWAY_SSL: process.env.GATEWAY_SSL, | |||
WEBSOCKETS_SERVER: process.env.WEBSOCKETS_SERVER, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no hay default aqui
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's on packages/env/src/index.ts
websockets until infra is ready
a42ff43
to
9c43369
Compare
What?
We want to keep the client informed when evaluations are running. How many logs are created, and how many logs fail
This PR set up a new Express server that set up a Socket.IO websocket server with 2 endpoints /websocket and worker-websocket. The one for the web has secure cookies token auth and the one for workers share a secret token between Sockets server and workers.
I think this setup makes sense
Screen.Recording.2024-09-16.at.13.56.54.mov
TODO
web
when user login with magic link.<WebsocketsProvider />
in React client so it can start listening to eventsWEB
WORKERS
total
is 0? REVIEW thislogout
lol we didn't have itlogout
Next PR
ws
orwss
(Secure). Maybe is not necessary because is behind a proxy cc @geclos