question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Task Eventstreams in the scaffolder not being cleaned up properly

See original GitHub issue

After upgrading our backstage repo to the most recent changes we have noticed that sometimes the eventstream crashes and then appears to stall the log output to the screen. From further investigation this appears to happen when there are stale eventstreams in the background from previous runs that are still ongoing.

Screen Shot 2021-04-29 at 9 22 45 AM

From further investigation it also seems like it may occurs if the eventstream fails and it needs to reconnnect, the new event stream is opened and it gets the completed log but never updates the UI unless you refresh the page.

FWIW we are also still trying to figure out why start getting net::ERR_HTTP2_PROTOCOL_ERROR 200 errors.

Expected Behavior

The expected behavior is for there to ever only be one eventstream that we are listening to and for it to successfully reconnect to just that eventstream upon crashing, leading to the scaffolder to complete successfully even if ran multiple times in a row.

Also if an eventstream fails and reconnects it should accurately reflect the new eventstream’s logs in the UI.

Current Behavior

When you run the scaffolder multiple times in a row in one session, there are stale eventstreams that cause the scaffolder to look as if it hasn’t completed because it’s trying to read state from multiple streams. Once refreshing the page it works as intended.

If an eventstream fails and it creates a new one, it’s logs are not reflected in the UI

Possible Solution

Not sure but assuming it has something to do with react hooks/memo keeping stale information around

There may be both a FE and BE issue that need to be solved. Should we close the eventstreams https://github.com/backstage/backstage/blob/cbfa75bf69da90961daae517f28a106327ceb5d0/plugins/scaffolder/src/api.ts#L217 in this area of code by calling eventSource.close() on both error and completion events?

And then the FE issue seems to be that after reconnecting to an eventStream (because of a client side failure) it doesn’t update the log state in the UI.

Steps to Reproduce

1.Scaffold out a template in backstage 2. then without refreshing go back and scaffold out another one as well

For us this is pretty consistent in recreating the behaviour.

However after further debugging, we have also noticed that if the eventstream fails before completion and reconnects it does not update the new eventstream logs in the UI. Appearing stuck unless you refresh

Refreshing though seems to make things work as intended.

Context

We were in the process of updating our fork of backstage with upstream changes

Your Environment

  • NodeJS Version (v12): 12.16.2
  • Operating System and Version (e.g. Ubuntu 14.04): linux (this is happening in our dev environment but would happen locally as well I believe)
  • Browser Information: chrome

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
jrusso1020commented, May 18, 2021

thanks @freben @benjdlambert let me give that a try and see if it helps!

1reaction
frebencommented, May 17, 2021

Yep, a keepalive comment message makes sense. It sounds good to be driven from the router as you initially tried, not the TaskWorker. However you probably need to put a res.flush(); after each write.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confluent Platform Component Changelogs
PR-8830 - fix: Set the sslFactory properly for the SR REST client. ... KAFKA-13533: Clean up resources correctly when task initialization fails in...
Read more >
Using Cloud SQL for PostgreSQL with Rails 5 | Ruby
The easiest way to eliminate billing is to delete the project that you created for the tutorial. To delete the project: Caution: Deleting...
Read more >
Sessions - Code PaLOUsa 2022
This workshop is designed to be hands-on experiences on how developers can get started with scaffolding serverless functions projects using Quarkus, a new ......
Read more >
Tag: Tutorial - KIZU 514
PHP and Golang, together at last! This blog post is about Spiral Framework and Roadrunner Server. I'll briefly talk about what they are,...
Read more >
Post-installation tasks - IBM Event Streams
Post-installation tasks after successfully installing IBM Event Streams. ... Ensure your OpenShift router is set up as required.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found