Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unobserved Task exceptions #2841

Open
WLink-0 opened this issue Nov 24, 2022 · 2 comments
Open

Unobserved Task exceptions #2841

WLink-0 opened this issue Nov 24, 2022 · 2 comments

Comments

@WLink-0
Copy link

WLink-0 commented Nov 24, 2022

  • TShock version: 5.1.2.0
  • TShock build number (if known):

Reproduction steps (if applicable)?

  1. Add TaskScheduler.UnobservedTaskException Event to TShockAPI (i added this on TShock.cs) or use a plugin with it (SEconomy for example)
  2. Join to the server and leave
  3. When you join or leave the server sometimes a System.AggregateException Shows up

Any stack traces or error messages (if known)?

System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (An established connection was aborted by the software in your host machine.)
 ---> System.Net.Sockets.SocketException (10053): An established connection was aborted by the software in your host machine.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.SendAsync(Socket socket, CancellationToken cancellationToken)
   at System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state)
   at TShockAPI.Sockets.LinuxTcpSocket.Terraria.Net.Sockets.ISocket.AsyncSend(Byte[] data, Int32 offset, Int32 size, SocketSendCallback callback, Object state) in /home/runner/work/TShock/TShock/TShockAPI/Sockets/LinuxTcpSocket.cs:line 143
   at DMD<Terraria.Net.NetManager::SendData>(NetManager this, ISocket socket, NetPacket packet)
   at Hook<Terraria.Net.NetManager::SendData>?43875021(NetManager , ISocket , NetPacket )
   at Terraria.GameContent.NetModules.NetLiquidModule.PrepareAndSendToEachPlayerSeparately()
   at Terraria.Liquid.UpdateLiquid()
   at Terraria.WorldGen.UpdateWorld()
   at Terraria.Main.DoUpdateInWorld(Stopwatch sw)
   at Terraria.Main.DoUpdate(GameTime& gameTime)
   at DMD<Terraria.Main::Update>(Main this, GameTime gameTime)
   at TerrariaApi.Server.Hooking.GameHooks.OnUpdate(orig_Update orig, Main instance, GameTime gameTime) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/TerrariaApi.Server/Hooking/GameHooks.cs:line 31
   at Terraria.Main.DedServ()
   at Terraria.Program.orig_RunGame()
   at Terraria.Program.RunGame()
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)
   at Terraria.WindowsLaunch.orig_Main(String[] args)
   at Terraria.WindowsLaunch.Main(String[] args)
   at TerrariaApi.Server.Program.StartServer(String[] args) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/Program.cs:line 123
   at TerrariaApi.Server.Program.Main(String[] args) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/Program.cs:line 106
   at Program.<>c__DisplayClass0_0.<<Main>$>g__Start|1() in /home/runner/work/TShock/TShock/TShockLauncher/Program.cs:line 65
   at Program.<Main>$(String[] args) in /home/runner/work/TShock/TShock/TShockLauncher/Program.cs:line 35
--- End of stack trace from previous location ---

   --- End of inner exception stack trace ---

Any log messages from files that end in .log or .txt? What are the last 100 log messages from the server console?

2022-11-24_02-21-01 (with DebugLogs set to true).log
2022-11-24_02-19-02.log

What plugins and what versions of those plugins are you running?

Only TShockAPI, no other plugins.

@Arthri
Copy link
Contributor

Arthri commented Nov 24, 2022

Add TaskScheduler.UnobservedTaskException Event to TShockAPI (i added this on TShock.cs) or use a plugin with it (SEconomy for example)

Hello! Can you elaborate on this part? what code did you add?

@WLink-0
Copy link
Author

WLink-0 commented Nov 24, 2022

I added this on initialize part of tshock.cs
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

protected void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
	if (e.Observed == true)
	{
		return;
	}
	TShock.Log.ConsoleError(e.Exception.Flatten().ToString());
	e.SetObserved();
}

And this on dispose
TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException;

EDIT: This error started to show up when i updated to tshock 5, it never happened to me before.
Here is some images of where i put the code
Initialize
Unobserved_task
Dispose

@WLink-0 WLink-0 changed the title System.AggregateExceptions Unobserved Task exceptions Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants