Should I wrap all web requests in pcall?

Due to the recent problems, my game was unfunctional since ROBLOX web requests were not working at the time, such as the Gamepass function. I already wrap datastores in pcall, but should I wrap every web request in one? such as gamepasses, profile pic loader, etc

1 Like

Yes it’ll catch any errors and it’ll prevent your script from breaking if the request fails

Absolutely! You never know when a web request may fail. Vanilla pcall can be a bit cumbersome though; have you looked into the design of Promises? A library I know of that implements promises tailored for Roblox can be found here.

1 Like

You should think of pcalls as necessary for any service or method that involves the use of a source outside of your server. So: web services, datastores, other servers, etc.

2 Likes

It’s a must for how unreliable Roblox’s services have been recently. I had to use pcall recently when one of my scripts that made web requests kept breaking.

You should always be using pcall by default. Never wait to use one until an error happens.

Note: Some people think I’m referring to using pcalls for everything. I meant using it for anything related to my response above. Sorry for the misclarification.

1 Like