Skip to content

[browser][wasm] Handle null task exception message #38803

@kjpou1

Description

@kjpou1

Executing the following:

			Task testTask = null;
			await testTask;

Will print the following.

dotnet.js:8653 Uncaught (in promise) System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Test.Client.Main(JSObject output)
   --- End of inner exception stack trace ---

Other times it prints something like the following with a tp callback threw a System.NullReferenceException

dotnet.js:2356 
dotnet.js:2356 Unhandled Exception:
dotnet.js:2356 System.NullReferenceException: Object reference not set to an instance of an object.
dotnet.js:2356    at Test.Client.CloseWebSocket(String closeReason)
dotnet.js:2356    at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__140_1(Object state)
dotnet.js:2356    at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
dotnet.js:2356    at System.Threading.ThreadPoolWorkQueue.Dispatch()
dotnet.js:2356    at System.Threading.ThreadPool.Callback()
dotnet.js:2344 tp callback threw a System.NullReferenceException

Code lines:

https://github.com/dotnet/runtime/blob/master/src/mono/mono/mini/mini-wasm.c#L606-L615

	if (!is_ok (error)) {
		printf ("tp callback failed due to %s\n", mono_error_get_message (error));
		mono_error_cleanup (error);
	}

	if (exc) {
		char *type_name = mono_type_get_full_name (mono_object_class (exc));
		printf ("tp callback threw a %s\n", type_name);
		g_free (type_name);
	}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions