Condition "requesting" is true. Returned: ERR_BUSY

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By soeng kanel

I am making the HTML5 game with godot engine. and API server using nodejs/expressjs.

here is my code to save the score once game is over.

func game_over():
$EndSound.play()
playing = false
$GameTimer.stop()
$Timer.stop()
set_process(false)
var time = OS.get_datetime()
var milisec = OS.get_ticks_msec()
playerscore.uid =  Hanzo.user_info.id
playerscore.score = score
Hanzo.save_score(playerscore, http) #calling function
for coin in $CoinContainer.get_children():
	coin.queue_free()

$HUD.show_game_over()
$Player.die()

and here is the function for saving the score on cloud Firestore function

func save_score(fields: Dictionary, http: HTTPRequest) ->void:
   var url := "%s/developers/%s/projects/%s" % [HANZO_API_URL, developer_id, pid] 
   var document := { "fields": fields }
   var body := to_json(document)
   print("saving doc.");
   var error = http.request(url, _get_request_headers(), false, HTTPClient.METHOD_POST, body)
   if error != OK:
	  push_error("An error occurred in the HTTP request.")

first time started the game play then game over → saved score successfully.
after game over I play again the game over-> I got this error message in my chrome console log error.

index.js:8 ERROR: Condition “requesting” is true. Returned:
ERR_BUSY index.js:8 At: scene/main/http_request.cpp:90:request() -
Condition “requesting” is true. Returned: ERR_BUSY

Any recommend to handle this error?

:bust_in_silhouette: Reply From: soeng kanel

Sorry everyone, i have fixed this issue .

Why this happen?

When I submitted the request to server nodejs I need to return with success status code.
so the server will response success instead if pending which mean server is busy and that is the reason make gogot return the ERR_BUSY

for my case , I need to something like this:

App.post('/save_score', function(req, res) {
        const result = ref.update(update_data); // update existing the document
        res.status(200).send({id: result.id, "state": true});
    });