TeleportService Errors shouldn't crash scripts

Issue:
With TeleportService, we have been seeing random errors that cause our scripts to crash. According to the TeleportService API, the Teleport methods should fire the TeleportInitFailed event when they fail.

However we have been seeing weird errors that are not documented anywhere:
image
This was when using TeleportPartyAsync, which the API says should fire that event mentioned above.

Solution:
All TeleportService methods should support the failed event so the developer can get context regarding the failure and handle it appropriately. I do not believe developers should have to pcall every Roblox API that might use a web endpoint, especially when there is a failure case already set up!

4 Likes

Doesn’t the documentation say specifically to use pcall with web apis?

eg:

Functions like SetAsync() that access a data store’s contents are network calls that may occasionally fail. As shown above, it’s recommended that these calls be wrapped in pcall() to catch and handle errors.

edit to add, the example code actually has pcall in it:

  • local success, result = pcall(function()
  1. return TeleportService:TeleportPartyAsync(placeId, playerList)
  2. end)

None of the TeleportService APIs, documentation or example code mentions using pcalls.

This includes the example code on how to use the TeleportInitFailed (scroll to Code Samples) It doesn’t make sense to have a Failure event if the API itself will still throw errors.

I also strongly disagree with having developers wrapping Roblox APIs in pcalls (custom web calls sure). Reimplementing all of this try-catch behavior for teleports, datastores, gamepasses, etc in every project does not benefit developers trying to build projects.

1 Like

They do, sorry I added it in an edit.

I’d agree with a feature enhancement request here. Prewrap the calls in pcall for the developers. Makes more sense doing it once rather than thousands of times…

1 Like

You’re right about the documentation for TeleportPartyAsync showing pcall. But none of the documentation for these show a pcall being used:

Teleport
TeleportToPrivateServer
TeleportToPlaceInstance
TeleportToSpawnByName

I filed this as a bug, because all of the example code listed above can crash in live games. Either those need to be updated to show how to properly handle errors with TeleportService, or fixing the error event would do the trick!

1 Like

Hmm, are you sure those aren’t already wrapped in pcall? Do you have a specific error using those apis? Perhaps there is a reason why they are forcing pcall with yielding functions. I am a bit new to lua, I must admit.