POST doesn't close the connection when 204 response used
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 78
- PR merge metrics
- No merged PRs in 30d
Description
## What you did:
Created a POST route
`{
"id": "8e54c04a-21fd-4cb3-b8de-1aa5a9ef988e",
"route": "/events",
"httpMethod": "POST",
"statusCode": "204",
"delay": "0",
"payload": {
"success": true
},
"headers": [
{
"id": "6ffb195d-c434-46da-a08c-52090415c949",
"header": "Retry-After",
"value": "60"
}
],
"disabled": false
}`
that responds with a HTTP 204 with a simple body of `{ success: true }` and posted:
`curl --request POST '169.254.241.176:3000/events' --header 'Content-Type: application/json' --data-raw '[{"eventId":"fbf1de19-8629-45d3-ad0f-34b8e17d594f","sessionId":"07726e3d-68ed-49a2-bb37-d1372e941191","dateTime":"2020-08-14T01:45:44.975Z","eventType":"App Launched","category":"engagement","latitude":40.4543,"longitude":41.4563},{"eventId":"37314774-d52b-4219-b5c4-e3b2c14aeda0","sessionId":"48830e55-33b2-4a8e-b5c7-710b85b44bf5","dateTime":"2020-08-14T01:56:53.220Z","eventType":"view cart","category":"engagement","latitude":40.4543,"longitude":41.4563,"sku":"abc123","price":10.95},{"eventId":"6c8a2370-0fb0-4c47-8914-11a8e2ffe47f","sessionId":"48830e55-33b2-4a8e-b5c7-710b85b44bf5","dateTime":"2020-08-14T01:57:23.341Z","eventType":"App Launched","category","engagement","latitude":40.4543,"longitude":41.4563}]'`
## What happened:
The body isn't delivered for ~90 seconds -- my connection timeout on the client is set to 30 seconds.
## Problem description:
Because it should immediately respond and close the connection?
## Suggested solution:
Changing nothing other than the response code back to HTTP 200 fixes the problem (the route responds instantaneously), but I would like to emulate several of the available responses, and I specifically need the 204 response for this POST :)
Contributor guide
Research direction
Start by reproducing the POST /events route with status 204 and the provided curl request, then trace the response-handling entry point for 204 responses. Done means the client receives the response immediately and the connection closes as expected, with a regression test covering this route behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100