Skip to content
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

Fix duplicate events on reinit #5424

Merged
merged 1 commit into from
Dec 5, 2024
Merged

Fix duplicate events on reinit #5424

merged 1 commit into from
Dec 5, 2024

Conversation

tofarr
Copy link
Collaborator

@tofarr tofarr commented Dec 5, 2024

Fix duplicate events on re-initialize

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

The frontend code maintains a variable containing the last event from the event stream on the server received over the socket. It uses this when a reinitialization occurs to make sure that the full event stream is not sent over the socket again.

However, the socket does not just contain events from the event stream - it also contains other pseudo events that do not have an ID - for example:

  • {token: "******", status: "ok"}
  • {status_update: true, type: "info", id: "STATUS$CONTAINER_STARTED", message: "Container started"}

If one of these happened to be the last event received, then the stream was duplicated.

This PR updates the stream to only store a last event if it has a numeric id.


#5358


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:139ba40-nikolaik   --name openhands-app-139ba40   docker.all-hands.dev/all-hands-ai/openhands:139ba40

@tofarr tofarr changed the title Fix duplicate events on init Fix duplicate events on reinit Dec 5, 2024
@tofarr tofarr requested a review from enyst December 5, 2024 15:39
@tofarr tofarr marked this pull request as ready for review December 5, 2024 15:42
@enyst
Copy link
Collaborator

enyst commented Dec 5, 2024

This makes sense, thank you!

I think Stephan's version may be a little better?

@tofarr tofarr merged commit 027c642 into main Dec 5, 2024
19 checks passed
@tofarr tofarr deleted the fix-duplicate-events branch December 5, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants