Skip to content

Commit

Permalink
*Actually* fix the async crash
Browse files Browse the repository at this point in the history
- Just remove async, it'll be fiiiine.
  • Loading branch information
KazWolfe committed Dec 28, 2022
1 parent bab8f89 commit 7c4b2de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions FFXIVPlugin/Server/Controllers/ActionController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Dalamud.Logging;
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
Expand Down Expand Up @@ -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<HotbarSlotType>(type, out var slotType))
throw HttpException.NotFound(string.Format(UIStrings.ActionController_UnknownActionTypeError, type));

Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions FFXIVPlugin/Server/XIVDeckWebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: " +
Expand All @@ -92,7 +92,7 @@ private void ConfigureErrorHandlers() {
ErrorNotifier.ShowError(ex.Message ?? inner.Message, true);
}

await HttpExceptionHandler.Default(ctx, ex);
return HttpExceptionHandler.Default(ctx, ex);
};
}
}

0 comments on commit 7c4b2de

Please sign in to comment.