make_it_mojo branch crashes if a Web event viewer is closed
The web-based backend for kdesrc-build I'm using to test the frontend/backend separation using Mojolicious has an 'event viewer' view which is used during build. It works by serializing events and then streaming them to U/I observers like the JS-powered web page here.
I had implemented a scheme in kdesrc-build backend to store all events so they could be replayed, that way it wouldn't matter how long it took for the user to get the browser open. While now redundant (you should already be in the web page before you can start a build if you're using kdesrc-build --backend
), the feature is still there and works. I figured it should therefore work to open a second event viewer while the first one was going on.
And, it did work! It was pretty glorious in fact to switch between multiple tabs of the same build and see them both update.
But then I closed the second tab, and everything froze (right after kholidays failed to run cmake for some reason). Looking back at the kdesrc-build CLI output, there was a backtrace similar to this repeated multiple times filling up the scrollback:
* Failed to launch build for kholidays:
Transaction already destroyed at /kdesrc/src/extragear/utils/kdesrc-build/modules/web/BackendServer.pm line 370.
at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojolicious/Controller.pm line 203.
Mojolicious::Controller::send(Mojolicious::Controller=HASH(0x561905c09ca0), HASH(0x561905aea3e0)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/web/BackendServer.pm line 370
web::BackendServer::__ANON__(ksb::StatusMonitor=HASH(0x561905663b60), HASH(0x561905b37048)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/EventEmitter.pm line 15
Mojo::EventEmitter::emit(ksb::StatusMonitor=HASH(0x561905663b60), "newEvent", HASH(0x561905b37048)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/ksb/StatusMonitor.pm line 168
ksb::StatusMonitor::_announceEvent(ksb::StatusMonitor=HASH(0x561905663b60), HASH(0x561905b37048)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/ksb/StatusMonitor.pm line 103
ksb::StatusMonitor::markPhaseComplete(ksb::StatusMonitor=HASH(0x561905663b60), "kholidays", "build", "success", "elapsed", 4, "was_successful", 1, ...) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/ksb/BuildContext.pm line 680
ksb::BuildContext::markModulePhaseSucceeded(ksb::BuildContext=HASH(0x561905566740), "build", ksb::Module=HASH(0x5619058cc500), HASH(0x561905a398f8)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/ksb/Module.pm line 1259
ksb::Module::__ANON__(HASH(0x561905b3a5f8)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Promise.pm line 237
eval {...} called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Promise.pm line 237
Mojo::Promise::_then_cb(Mojo::Promise=HASH(0x561905a35f80), CODE(0x561905aea860), "resolve", HASH(0x561905b3a5f8)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Promise.pm line 98
Mojo::Promise::__ANON__(HASH(0x561905b3a5f8)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Promise.pm line 188
Mojo::Promise::__ANON__(Mojo::IOLoop=HASH(0x5619048fe198)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/IOLoop.pm line 78
Mojo::IOLoop::__ANON__(Mojo::Reactor::EV=HASH(0x561904935278)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Reactor/Poll.pm line 131
Mojo::Reactor::Poll::_next(Mojo::Reactor::EV=HASH(0x561904935278)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Reactor/Poll.pm line 146
eval {...} called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Reactor/Poll.pm line 146
Mojo::Reactor::Poll::_try(Mojo::Reactor::EV=HASH(0x561904935278), "Timer", CODE(0x5619048f7cc8)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Reactor/EV.pm line 70
Mojo::Reactor::EV::__ANON__(EV::Timer=SCALAR(0x561905b3c7f8), 256) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Reactor/EV.pm line 32
eval {...} called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/Reactor/EV.pm line 32
Mojo::Reactor::EV::start(Mojo::Reactor::EV=HASH(0x561904935278)) called at /kdesrc/src/extragear/utils/kdesrc-build/modules/Mojo/IOLoop.pm line 140
Mojo::IOLoop::start("Mojo::IOLoop") called at /home/kde-svn/bin/kdesrc-build line 197
main::launchBackend() called at /home/kde-svn/bin/kdesrc-build line 206
I suspect we need to add a handler in the backend for unexpectedly closed connections from the frontend. But it's already late so I'm going to forget it, so posting this here as a reminder to do it this weekend.