SaltyAom/bun-http-framework-benchmark

invalid tests

Kapsonfire-DE opened this issue · 7 comments

  • Kingworld is not responding correctly - neither the body is sent back nor it has the correct header
  • bun.ts is doubling json.stringify FIXED: #5

For KingWorld exp.23 has a breaking change reading body, mentioned in Change log
My guess is that you updated to KingWorld exp.24 and haven't updated the code here.
Screen Shot 2565-08-29 at 22 33 25

For KingWorld response header, I couldn't reproduce KingWorld the response header issue:
Screen Shot 2565-08-29 at 22 30 53

Not sure what happens but it would be great if you give me some information on what machine you're testing on or which scenario, or which Bun version (canary or stable)

For double JSON.stringify, I have merged your PR here, thanks for fixing that! #5

the content-type should be application/json
not text-plain

btw the content length in your screenshot seems to be wrong as well

I think you might mistake the test between 2 and 3.

Because the REST Client has a body editor from the previous request and isn't hidden (but is striped when requested) which is pretty common for most REST Clients like Postman, and Insomnia (both doesn't hide body editor on GET).

The above screenshot is for test 3 (take a look at URL), which parses path parameters and query string, not JSON. So it's expected to return text/plain, and content-length is correctly set because the endpoint return 1 benchmark, which has 11 characters.

Here's a definition for test 3 (screenshot above)

Test 3 (screenshot above)

Params, query & header
[GET] /id/:id
Extract path params, query and header.
For this benchmark, request url will be send as: /id/1?name=bun
Set x-powered-by to benchmark
Expected response: "1 bun" (${id} ${query})

Test 2 (which you mistake for the screenshot)

Post JSON
[POST] /json
Mirror body to response
For the benchmark, request body will be send as: { "hello": "world" }
Expected response: { "hello": "world" }

For clarification, here are the response body and response headers for both tests.

Test 2 (JSON):

Screen Shot 2565-08-31 at 22 27 07

Screen Shot 2565-08-31 at 22 27 08

Test 3 (Path parameters and query string)

Screen Shot 2565-08-31 at 22 26 49

Screen Shot 2565-08-31 at 22 26 52

but still the json post test should send content-type application/json like the other frameworks do as well

From my previous comment, the JSON POST test correctly return content-type of application/json.
187719888-aa3da473-3946-4859-86ee-d349f914c8ae
187719903-fa7fe049-b949-4842-be02-2fe55fe5bae1

you'Re right - i tested it with a older version of kingworld and the older version of the bench code..