You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I try to send any of POST, PUT, DELETE requests using server-net, if I do not include a request body, the game crashes. I believe the game loop gets blocked since entities stop moving, blocks stop dropping themselves when mined, and I can't even send commands via the console.
To Reproduce
Steps to reproduce the behavior:
Create a script that sends a DELETE request to an API endpoint
Do not include a request body
Notice how entities stop moving
Also, notice on your API access logs that the request never came in
Expected behavior
DELETE request gets sent to the API and you don't crash your server
Screenshots
Console logs. Sends the requests. Notice how there is no response.
Changed the script code to include an empty JSON body. Notice the response.
Additional context
Simple code that accesses all 4 methods on an endpoint in the API and returns the response body.
Technically, DELETE requests shouldn't even have a request body so I never set one, and was so confused why it would crash.
import{http,HttpHeader,HttpRequest,HttpRequestMethod}from'@minecraft/server-net';system.run(()=>{constrequests=[newHttpRequest(`http://nexuscore:8000/api/v0.1/users/test`).setMethod(HttpRequestMethod.Get),newHttpRequest(`http://nexuscore:8000/api/v0.1/users/test`).setMethod(HttpRequestMethod.Put),newHttpRequest(`http://nexuscore:8000/api/v0.1/users/test`).setMethod(HttpRequestMethod.Post),newHttpRequest(`http://nexuscore:8000/api/v0.1/users/test`).setMethod(HttpRequestMethod.Delete),]for(constrequestofrequests){request.body=JSON.stringify({})// If you do not include this line, POST, PUT and DELETE requests crash the gamerequest.headers=[newHttpHeader("Content-Type","application/json"),newHttpHeader("auth","my-auth-token"),];console.log(request.uri,request.method)http.request(request).then((response)=>console.log(response.body))}})
The text was updated successfully, but these errors were encountered:
Describe the bug
When I try to send any of POST, PUT, DELETE requests using
server-net
, if I do not include a request body, the game crashes. I believe the game loop gets blocked since entities stop moving, blocks stop dropping themselves when mined, and I can't even send commands via the console.To Reproduce
Steps to reproduce the behavior:
DELETE
request to an API endpointExpected behavior
DELETE request gets sent to the API and you don't crash your server
Screenshots
Console logs. Sends the requests. Notice how there is no response.
Changed the script code to include an empty JSON body. Notice the response.
Additional context
Simple code that accesses all 4 methods on an endpoint in the API and returns the response body.
Technically, DELETE requests shouldn't even have a request body so I never set one, and was so confused why it would crash.
The text was updated successfully, but these errors were encountered: