Supressing mouse warnings from running server in --headless mode

Godot Version

4.2.1

Question

I have a client-server game set up where the server basically just runs the whole game along with the clients in order to simulate it/check inputs.

However, I run the server in --headless mode so it can be ran on a cloud server, and also because it doesn’t need any of the graphics.

When running in headless mode, I get a bunch of error messages:

ERROR: Mouse is not supported by this display server.
   at: mouse_get_position (servers/display_server.cpp:367)

I am assuming this is because several things in my game script make use of the mouse.

This doesn’t actually cause any problems, but the error is annoying and obscures useful debug info.

Is there any way to suppress it?

You could use the Feature Tags and OS.has_feature() to skip the mouse code in your scripts when building a server build.

Checking for mouse support should rather be done in DisaplyServer.has_feature() instead of in OS.

1 Like

We should silence this message upstream as there’s no reason for it to show up. This way, you won’t need to add any checks yourself.

Edit: Pull request opened: Don't print warning messages for DisplayServer functions in headless mode by Calinou · Pull Request #90549 · godotengine/godot · GitHub

3 Likes