Cannot modify config/delete bot "Async request error"

I’ve recently imported a bot, but when I try to modify it or delete it, I get an ‘Unexpected error’ appear in red in the top right of the screen.

Does anyone have any ideas why this might be happening? I’m running 12.2.3.

Upon deleting the bot, I get the following error in the console:

13:47:58.386 HTTP [Bots] Async request error Could not delete bot 'my-bot': Cannot read property 'stop' of undefined [VError, Could not delete bot 'my-bot': Cannot read property 'stop' of undefined]

Upon trying to update the config I get the following:

0|botpress-server  | 13:46:56.863 HTTP [Bots] Async request error Cannot read property 'stop' of undefined [TypeError, Cannot read property 'stop' of undefined]
0|botpress-server  | STACK TRACE
0|botpress-server  | TypeError: Cannot read property 'stop' of undefined
0|botpress-server  |     at Object.onBotUnmount (/home/ubuntu/botpress-server/modules/.cache/module__de6f8eab235c1f77fccb220c361b969b303f0529e2fabd23480bdb7349b64863/dist/backend/index.js:36:31)
0|botpress-server  |     at ModuleLoader.<anonymous> (/snapshot/build-linux/out/bp/core/module-loader.js:0:0)
0|botpress-server  |     at Generator.next (<anonymous>)
0|botpress-server  | From previous event:
0|botpress-server  |     at /snapshot/build-linux/out/bp/core/module-loader.js:0:0
0|botpress-server  | From previous event:
0|botpress-server  |     at step (/snapshot/build-linux/out/bp/core/module-loader.js:0:0)
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/module-loader.js:0:0)
0|botpress-server  | From previous event:
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/module-loader.js:0:0)
0|botpress-server  |     at ModuleLoader.unloadModulesForBot (/snapshot/build-linux/out/bp/core/module-loader.js:0:0)
0|botpress-server  | From previous event:
0|botpress-server  |     at step (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  | From previous event:
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  |     at BotService._localUnmount (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  |     at BotService.<anonymous> (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  |     at Generator.next (<anonymous>)
0|botpress-server  | From previous event:
0|botpress-server  |     at step (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  | From previous event:
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  |     at BotService.updateBot (/snapshot/build-linux/out/bp/core/services/bot-service.js:0:0)
0|botpress-server  |     at BotsRouter.<anonymous> (/snapshot/build-linux/out/bp/core/routers/admin/bots.js:0:0)
0|botpress-server  |     at Generator.next (<anonymous>)
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/routers/admin/bots.js:0:0)
0|botpress-server  | From previous event:
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/routers/admin/bots.js:0:0)
0|botpress-server  |     at setupRoutes.router.post.asyncMiddleware (/snapshot/build-linux/out/bp/core/routers/admin/bots.js:0:0)
0|botpress-server  |     at exports.asyncMiddleware.fn (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/route.js:137:13)
0|botpress-server  | From previous event:
0|botpress-server  |     at step (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  | From previous event:
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at exports.needPermissions (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/route.js:137:13)
0|botpress-server  |     at Route.dispatch (/snapshot/build-linux/node_modules/express/lib/router/route.js:112:3)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at /snapshot/build-linux/node_modules/express/lib/router/index.js:281:22
0|botpress-server  |     at param (/snapshot/build-linux/node_modules/express/lib/router/index.js:354:14)
0|botpress-server  |     at param (/snapshot/build-linux/node_modules/express/lib/router/index.js:365:14)
0|botpress-server  |     at Function.process_params (/snapshot/build-linux/node_modules/express/lib/router/index.js:410:3)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/index.js:275:10)
0|botpress-server  |     at Function.handle (/snapshot/build-linux/node_modules/express/lib/router/index.js:174:3)
0|botpress-server  |     at router (/snapshot/build-linux/node_modules/express/lib/router/index.js:47:12)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at trim_prefix (/snapshot/build-linux/node_modules/express/lib/router/index.js:317:13)
0|botpress-server  |     at /snapshot/build-linux/node_modules/express/lib/router/index.js:284:7
0|botpress-server  |     at Function.process_params (/snapshot/build-linux/node_modules/express/lib/router/index.js:335:12)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/index.js:275:10)
0|botpress-server  |     at Object.<anonymous> (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at Generator.next (<anonymous>)
0|botpress-server  |     at fulfilled (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at runCallback (timers.js:696:18)
0|botpress-server  |     at tryOnImmediate (timers.js:667:5)
0|botpress-server  |     at processImmediate (timers.js:649:5)
0|botpress-server  |     at process.topLevelDomainCallback (domain.js:121:23)
0|botpress-server  | From previous event:
0|botpress-server  |     at step (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  | From previous event:
0|botpress-server  |     at __awaiter (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at exports.checkTokenHeader (/snapshot/build-linux/out/bp/core/routers/util.js:0:0)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at trim_prefix (/snapshot/build-linux/node_modules/express/lib/router/index.js:317:13)
0|botpress-server  |     at /snapshot/build-linux/node_modules/express/lib/router/index.js:284:7
0|botpress-server  |     at Function.process_params (/snapshot/build-linux/node_modules/express/lib/router/index.js:335:12)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/index.js:275:10)
0|botpress-server  |     at Function.handle (/snapshot/build-linux/node_modules/express/lib/router/index.js:174:3)
0|botpress-server  |     at router (/snapshot/build-linux/node_modules/express/lib/router/index.js:47:12)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at trim_prefix (/snapshot/build-linux/node_modules/express/lib/router/index.js:317:13)
0|botpress-server  |     at /snapshot/build-linux/node_modules/express/lib/router/index.js:284:7
0|botpress-server  |     at Function.process_params (/snapshot/build-linux/node_modules/express/lib/router/index.js:335:12)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/index.js:275:10)
0|botpress-server  |     at map (/snapshot/build-linux/node_modules/express-urlrewrite/index.js:42:16)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at trim_prefix (/snapshot/build-linux/node_modules/express/lib/router/index.js:317:13)
0|botpress-server  |     at /snapshot/build-linux/node_modules/express/lib/router/index.js:284:7
0|botpress-server  |     at Function.process_params (/snapshot/build-linux/node_modules/express/lib/router/index.js:335:12)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/index.js:275:10)
0|botpress-server  |     at cors (/snapshot/build-linux/node_modules/cors/lib/index.js:188:7)
0|botpress-server  |     at /snapshot/build-linux/node_modules/cors/lib/index.js:224:17
0|botpress-server  |     at originCallback (/snapshot/build-linux/node_modules/cors/lib/index.js:214:15)
0|botpress-server  |     at /snapshot/build-linux/node_modules/cors/lib/index.js:219:13
0|botpress-server  |     at optionsCallback (/snapshot/build-linux/node_modules/cors/lib/index.js:199:9)
0|botpress-server  |     at corsMiddleware (/snapshot/build-linux/node_modules/cors/lib/index.js:204:7)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at trim_prefix (/snapshot/build-linux/node_modules/express/lib/router/index.js:317:13)
0|botpress-server  |     at /snapshot/build-linux/node_modules/express/lib/router/index.js:284:7
0|botpress-server  |     at Function.process_params (/snapshot/build-linux/node_modules/express/lib/router/index.js:335:12)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/index.js:275:10)
0|botpress-server  |     at urlencodedParser (/snapshot/build-linux/node_modules/body-parser/lib/types/urlencoded.js:82:7)
0|botpress-server  |     at HTTPServer.start.__awaiter.app.use (/snapshot/build-linux/out/bp/core/server.js:0:0)
0|botpress-server  |     at Layer.handle [as handle_request] (/snapshot/build-linux/node_modules/express/lib/router/layer.js:95:5)
0|botpress-server  |     at trim_prefix (/snapshot/build-linux/node_modules/express/lib/router/index.js:317:13)
0|botpress-server  |     at /snapshot/build-linux/node_modules/express/lib/router/index.js:284:7
0|botpress-server  |     at Function.process_params (/snapshot/build-linux/node_modules/express/lib/router/index.js:335:12)
0|botpress-server  |     at next (/snapshot/build-linux/node_modules/express/lib/router/index.js:275:10)
0|botpress-server  |     at /snapshot/build-linux/node_modules/body-parser/lib/read.js:130:5
0|botpress-server  |     at invokeCallback (/snapshot/build-linux/node_modules/raw-body/index.js:224:16)
0|botpress-server  |     at done (/snapshot/build-linux/node_modules/raw-body/index.js:213:7)
0|botpress-server  |     at IncomingMessage.onEnd (/snapshot/build-linux/node_modules/raw-body/index.js:273:7)
0|botpress-server  |     at IncomingMessage.emit (events.js:182:13)
0|botpress-server  |     at IncomingMessage.EventEmitter.emit (domain.js:442:20)
0|botpress-server  |     at endReadableNT (_stream_readable.js:1081:12)
0|botpress-server  |     at process._tickCallback (internal/process/next_tick.js:63:19)

It appears this happens if you use the environment variable USE_LEGACY_NLU (this was because of the following issue… https://github.com/botpress/botpress/issues/2655)