Closed LuckFire closed 2 months ago
It seems I'm definitely misunderstanding the use case of this, it definitely isn't some issue with the endpoint path and is something with my logic, still not sure what I'm doing wrong though after debugging and running their Python script since it works.
For some weird reason, when I modify my code to be this , it works..
await LuauExecutionApi
.executeLuau({
universeId: 3666294218, placeId: 9938675423,
script
})
.then(async ({ data }) => {
const taskId = data.path.split('/').slice(-1)[0];
await poll(LuauExecutionApi.luauExecutionTask, {
universeId: 3666294218, placeId: 9938675423,
sessionId: taskId, taskId: taskId
}, async ({ data }, stop) => {
console.log(data);
if (data.state !== 'COMPLETE') return;
stop();
})
})
.catch((e) => console.log(e));
EDIT: Nevermind, just randomly stopped working again!
Also, after looking at your docs a bit, I think you accidentally made sessionId
required for LuauExecutionApi.luauExecutionTask
, seeing how LuauExecutionApi.listLuauExecutionLogs
doesn't require it and the endpoint that the method uses has a variation without it.
Found out the issue! You have to provide the version, which openblox provides no real way to easily grab that. I was going to request this anyways, but it seems necessary now. This also seems to happen with LuauExecutionApi.listLuauExecutionLogs
.
If possible, could you guys add a way to grab the session id, task id, and version that is provided in the path with some sort of util?
EDIT: Another thing, it seems like there's no way to grab the result when the request is completed. You can make a type for where if there state is "COMPELTE"
, it will include the output (which should be typeset for custom data).
The LuauExecution docs are really confusing. It gives 4 different paths for each endpoint - some of which return 404.
EDIT: Another thing, it seems like there's no way to grab the result when the request is completed. You can make a type for where if there state is "COMPELTE", it will include the output (which should be typeset for custom data).
The example for luauExecutionTask
has this by setting the task
variable to the data once the state is COMPLETE
.
I was pulling my hair out trying to figure out what I was doing wrong, all it was is version
missing 😅 glad but upset at the same time to see this was Roblox's own issue.
The example for
luauExecutionTask
has this by setting thetask
variable to the data once the state isCOMPLETE
.
What I meant was, I cannot do data.output.results
because the types aren't provided for it, so the compiler just yells at me when I try to set it to the data.
Oh I see. my apologies for the misunderstanding. I can add a type argument to the luauExecutionTask
to allow the results
field to be typed which should fix this issue.
Awesome, that'd be great
Hey, not to rush you guys or anything, any idea on when the type argument may be pushed? If you guys are unavailable I'll happily make a PR adding it
Just need it before I can push code for something so I'm wondering how long it'll be 😅
Changes should be merged soon. My apologies for the delay.
Changes have now been pushed in v1.0.53
. I appreciate your patience 😅.
poll
has been renamed to pollMethod
and the method is now no longer separate from its arguments to accommodate type arguments.universeId
, placeId
, version
, sessionId
and taskId
and adds them to the response data.LuauExecutionApi.luauExecutionTask
is now typed correctly and has a type argument for defining the type for its results
.pollHttp
helper.Awesome! Though I think there's a slight issue with the types for results. It seems like it's typed to only have output
, even tho the way it's returned is
{
"output": {
"results": []
}
}
EDIT: nevermind, I think it was being weird cause I never set the types! whoops 😅
Oh btw heres an updated example of executing luau and then polling for it to complete. You'll be pleased to know that theres no longer any funny business with having that task
variable 😅.
const { data:{ universeId, placeId, version, sessionId, taskId } } = await LuauExecutionApi.executeLuau({
universeId: 5795192361, placeId: 16866553538, script: `local x, y = 3, 4; return x + y`
})
type Results = number[]
const { data:executedTask } = await pollMethod(
LuauExecutionApi.luauExecutionTask<Results>({ universeId, placeId, version, sessionId, taskId }),
async ({ data }, stopPolling) => data.state === "COMPLETE" && stopPolling()
)
console.log(!executedTask.error && executedTask.output.results)
If you are running into any other issues regarding the LuauExecution
then do be sure to open up a new ticket. 😅
Yes I saw, thank you for adding that! Everything is working perfectly now, appreciate your work so much 🙏 genuine life saver
Hey, not sure if I should make a separate issue for this or not so I decided to go back to this one where it was originally discussed.
Any plans on removing the console.log where it prints out that it's polling the method? Just a very nit-picky thing since I like to have control over what's being output into my log, if it's necessary maybe put it behind some debug log flag?
sure, I can make a debug log flag. The main purpose of this particular log was so that people wouldn't think that openblox was infinitely hanging - but yea I can see how this can be annoying.
When running this method, the endpoint that is being requested is
/cloud/v2/universes/3666294218/places/9938675423/luau-execution-sessions/{session_id}/tasks/{task_id}
.I could be completely wrong, but based on the Open Cloud docs, the endpoint that should be requested is
/cloud/v2/universes/{universe}/places/{place}/luau-execution-session-tasks/{task_id}
. Unless there is a different method / something I have to do to make it request this endpoint, this seems correct.Here is the code I am running: