Page MenuHomeFeedback Tracker

RestApi cb is broken
Acknowledged, NormalPublic

Description

Since the last update 0.9.7.41 callbacks for RestApi requests are broken.

It seems that there is no strong reference set to the callback so the callback object gets destroyed immediatly.

string a = "https://webhook.site/xxxxxxxxx";
RestContext ctx = GetGame().GetRestApi().GetContext(a);
auto myCbThatWontBeTriggered = RestCallback2();
ctx.POST(myCbThatWontBeTriggered, "","bla data");

A workaround is to give the callback a strong reference by your own via an array/map or so.

ref array<ref RestCallback2> GlobalCbBuffer = {};

void TestFnc() {
	string a = "https://webhook.site/xxxxxxxxx";
	RestContext ctx = GetGame().GetRestApi().GetContext(a);
	
	auto myCbThatWillBeTriggeredNow = RestCallback2();
	GlobalCbBuffer.Insert(myCbThatWillBeTriggeredNow);
	
	ctx.POST(myCbThatWillBeTriggeredNow , "","bla data");
}

TestFnc();

In addition to that it occurs an error sometimes during compiling:

SCRIPT       : Reloading game scripts
SCRIPT       : Script validation
SCRIPT    (E): Leaked 'RestContext' script instance (1x)!
SCRIPT       : Compiling GameLib scripts
SCRIPT       : Compiling Game scripts

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

RamBob created this task.Dec 1 2022, 4:06 PM
Geez changed the task status from New to Acknowledged.Dec 1 2022, 4:09 PM
Geez added a subscriber: Geez.Dec 1 2022, 4:11 PM

Thank you for the report RamBob.
We are aware of this problem and are looking into fixing it.
Regards,
Geez