I found a potential issue for a hanging await. He is my example code which should help explain things:
func check_if_doc_exists(player_name) -> int:
var document_task = scores_collection.get_doc(player_name)
var document = await document_task.get_document
if document != null:
return document.doc_fields.score
return 0
In the code above, if the get_doc emits a task_error signal the await document_task.get_document will never return and I think it just hangs there.
One way to solve this currently is to use await document_task.task_finished instead but that seems a bit confusing to newcomers to the library like myself. To me, it makes sense to await the expected signal and check if the returned value is correct or not. Returning a null or empty array on error seems like a good value to return, which can also be easily handled.
On delete document I see the library isn't returning anything here but this could create the same hanging await issue. So I thought of returning a success bool whether it was successful or not. Allowing me to handle errors more easily in the code.
Let me know if this sounds like a good idea. Thanks
I found a potential issue for a hanging await. He is my example code which should help explain things:
In the code above, if the
get_doc
emits atask_error
signal theawait document_task.get_document
will never return and I think it just hangs there.One way to solve this currently is to use
await document_task.task_finished
instead but that seems a bit confusing to newcomers to the library like myself. To me, it makes sense to await the expected signal and check if the returned value is correct or not. Returning a null or empty array on error seems like a good value to return, which can also be easily handled.On delete document I see the library isn't returning anything here but this could create the same hanging await issue. So I thought of returning a success bool whether it was successful or not. Allowing me to handle errors more easily in the code.
Let me know if this sounds like a good idea. Thanks