From 7c4b2decc236f9c02e9229c16a97dadf005113db Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Wed, 28 Dec 2022 01:10:26 -0800 Subject: [PATCH] *Actually* fix the async crash - Just remove async, it'll be fiiiine. --- FFXIVPlugin/Server/Controllers/ActionController.cs | 7 +++++-- FFXIVPlugin/Server/XIVDeckWebServer.cs | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/FFXIVPlugin/Server/Controllers/ActionController.cs b/FFXIVPlugin/Server/Controllers/ActionController.cs index 896cdb8..c624204 100644 --- a/FFXIVPlugin/Server/Controllers/ActionController.cs +++ b/FFXIVPlugin/Server/Controllers/ActionController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Dalamud.Logging; using EmbedIO; using EmbedIO.Routing; using EmbedIO.WebApi; @@ -58,7 +59,7 @@ public ExecutableAction GetAction(string type, int id) { } [Route(HttpVerbs.Post, "/{type}/{id}/execute")] - public async void ExecuteAction(string type, int id) { + public void ExecuteAction(string type, int id) { if (!Enum.TryParse(type, out var slotType)) throw HttpException.NotFound(string.Format(UIStrings.ActionController_UnknownActionTypeError, type)); @@ -70,8 +71,10 @@ public async void ExecuteAction(string type, int id) { ActionPayload? payload = null; if (payloadType != null) { - var requestBody = await this.HttpContext.GetRequestBodyAsStringAsync(); + var requestBody = this.HttpContext.GetRequestBodyAsStringAsync().Result; payload = JsonConvert.DeserializeObject(requestBody, payloadType) as ActionPayload; + + PluginLog.Debug($"Body: {requestBody}\nPayload: {payload}"); } GameUtils.ResetAFKTimer(); diff --git a/FFXIVPlugin/Server/XIVDeckWebServer.cs b/FFXIVPlugin/Server/XIVDeckWebServer.cs index c7d42e9..c10009a 100644 --- a/FFXIVPlugin/Server/XIVDeckWebServer.cs +++ b/FFXIVPlugin/Server/XIVDeckWebServer.cs @@ -60,7 +60,7 @@ private static string[] GenerateUrlPrefixes(int port) { } private void ConfigureErrorHandlers() { - this._host.OnUnhandledException = async (ctx, ex) => { + this._host.OnUnhandledException = (ctx, ex) => { // Handle known exception types first, as these can be thrown by various subsystems switch (ex) { case ActionLockedException: @@ -78,10 +78,10 @@ private void ConfigureErrorHandlers() { PluginLog.Error(ex, $"Unhandled exception while processing request: " + $"{ctx.Request.HttpMethod} {ctx.Request.Url.PathAndQuery}"); ErrorNotifier.ShowError(ex.Message, debounce: true); - await ExceptionHandler.Default(ctx, ex); + return ExceptionHandler.Default(ctx, ex); }; - this._host.OnHttpException = async (ctx, ex) => { + this._host.OnHttpException = (ctx, ex) => { var inner = ex.DataObject as Exception ?? (HttpException) ex; PluginLog.Warning(inner, $"Got HTTP {ex.StatusCode} while processing request: " + @@ -92,7 +92,7 @@ private void ConfigureErrorHandlers() { ErrorNotifier.ShowError(ex.Message ?? inner.Message, true); } - await HttpExceptionHandler.Default(ctx, ex); + return HttpExceptionHandler.Default(ctx, ex); }; } }