Could not send message '<unknown>' from 'game:<unknown>#<unknown>' to '<unknown>:<unknown>'

First of all - I’m sure this is somehow rooted in my code, but I’m not really sure what it means and why it’s happening:

Could not send message '<unknown>' from 'game:<unknown>#<unknown>' to '<unknown>:<unknown>'.

It doesn’t happen to me, but I have had it reported from my users. It’s happened both in Windows and Linux.

My biggest clue is that it seems to happen on a new game, and the message in question is from one collection proxy to another. Perhaps something to do with the collection proxies not being loaded? Not sure how that would be possible, because my setup is such that the collection proxy where the message originates (“game”) is loaded after the target collection proxy (“HUD”).

I had HUD set to “async_load” (with “enable” passed as soon as the collection is loaded), with the game not beginning to load until the “proxy_loaded” message was received. Could that be part of the issue? Would changing HUD to regular load make a difference?

Sorry for the vague question, it’s hard for me to troubleshoot this because I can’t reproduce it on my machine.

How does the problem manifest itself to the user? Does that message show up in a log somewhere?

You could monkey patch msg.post and add some additional log message before calling the real msg.post function to help you trace the code flow and where the message originates from and what happened prior to the error.

2 Likes

I’m not entirely sure how the issue manifests. I think it is linked to a failure to load a new map, because I have some reports of users saying they get just a black screen but sounds etc are still playing. Not very helpful, I know.

The message is extracted from error logs captured locally by Err / errors sent to me automatically via analytics.

As Björn mentions, you could try to monkey patch the msg.post function so you can inject your own diagnostics.

Something like this:

local msg_post = msg.post

msg.post = function(receiver, message_id, message)
	local ok, err = pcall(msg_post, receiver, message_id, message)
	if not ok then
		print("Unable to send message", message_id, " to ", receiver)
	end
end
2 Likes

Thanks for that. I will see about putting something like that in the offending scripts.

No, put it in one of the first scripts that you load in the entire project. The snippet of code I shared replaces the original functionality of msg.post. You want to do that once at the beginning of your project.

My bad. The “local” tag threw me. Won’t that make the redefined function only apply in the scope of the script I put this in? Maybe you just wrote the example quickly and it’s not supposed to be “local”, otherwise I am confused.

I’m storing the original and global msg.post in a local variable and then replacing the global function with my own custom function. The custom function adds error checking when it uses the now locally stored original function.