Error not displaying source correctly

Behaviour: Shows the local script as source of the error
Expected behaviour: Show the server-sided script as source of the error

How to reproduce:

Put a RemoteFunction in ReplicatedStorage

Create a server-sided Script:

game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function()
    game.MarketplaceService:GetProductInfo(1)
end

Create a client-sided LocalScript:

game.ReplicatedStorage.RemoteFunction:InvokeServer()

Place File (46.2 KB)

3 Likes

Clients cant see the servers errors
Try checking the server’s output ig

The studio output shows both server and client. That’s why it’s a bug report and not scripting support.

After looking at the docs, I understand the confusion, I believe this is as designed though, if the server would handle the error, the client would hang (yield) forever. Instead the server returns with the error to the Client where the error is displayed.

You can wrap your Http call in a pcall (as is often recommended with functions that can throw) and handle the error on the server side or log the error on the server side and rethrow so the client(s) also know about it.

1 Like

I understand. However, httperrors are not the only errors that can happen. Often there are simply errors in the script. My game uses a lot of remote functions, slowing down development due to more complicated debugging. I don’t think using pcalls everywhere is the ultimate solution, but rather passing the source of the error to the client. Could you pass this on to feature requests?
Thank you very much!

2 Likes

The recommendation for this is to use RemoteEvents – you can still send arguments with the remote events, however because they are async, there is no risk of infinite yield:

Your code would result in a server error changed to:
Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:FindFirstChildOfClass("RemoteEvent")

remoteEvent.OnServerEvent:Connect(function()
	game.MarketplaceService:GetProductInfo(1)
end)

LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:FindFirstChildOfClass("RemoteEvent")

remoteEvent:FireServer()

Error:

  09:52:02.172  error.rbxl auto-recovery file was created  -  Studio
  09:52:04.353  MarketplaceService:getProductInfo() failed because HTTP 400 (Bad Request)  -  Server - Script:5
  09:52:04.353  Stack Begin  -  Studio
  09:52:04.353  Script 'ServerScriptService.Script', Line 5  -  Studio - Script:5
  09:52:04.353  Stack End  -  Studio

Hope this helps…