question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Smee seems to reformat JSON without updating Content-Length header

See original GitHub issue

Hi,

I am using smee-client in front of a custom Node app. During my tests using curl, I noticed the following kind of error from it:

Error: socket hang up
    at connResetException (internal/errors.js:570:14)
    at Socket.socketOnEnd (_http_client.js:440:23)
    at Socket.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1183:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  code: 'ECONNRESET',
  response: undefined
}

By observing the payload, I finally realized that the ‘Content-Length’ header coming from smee client was still equal to what my curl command was sending whereas the JSON payload itself had been reformatted to a compact format.

This leads my app to hang, waiting for more bytes to come from the smee client:

BadRequestError: request aborted
    at IncomingMessage.onAborted (/app/node_modules/raw-body/index.js:231:10)
    at IncomingMessage.emit (events.js:210:5)
    at abortIncoming (_http_server.js:492:9)
    at socketOnClose (_http_server.js:485:3)
    at Socket.emit (events.js:215:7)
    at TCP.<anonymous> (net.js:658:12)

Simple example to reproduce:

curl https://smee.io/XXXXX --data '{ }' -H 'Content-Type: application/json'

The tcpdump trace of the corresponding HTTP request coming from smee client to my app:

POST / HTTP/1.1
host: smee.io
Accept-Encoding: gzip, deflate
user-agent: curl/7.54.0
content-type: application/json
connection: close
accept: */*
x-request-id: 3e3de197-3708-4dd2-8202-21c3f3e6ccd5
x-forwarded-for: 70.36.61.12
x-forwarded-proto: https
x-forwarded-port: 443
via: 1.1 vegur
connect-time: 0
x-request-start: 1572802450843
total-route-time: 0
content-length: 3
timestamp: 1572802450846

{}

I have no idea what part of the pipeline is at fault but I would expect that either the JSON format should be left alone or that the content length should be recalculated accordingly to the new format.

smee client version: 1.1.0

Thanks. Philippe

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:7

github_iconTop GitHub Comments

6reactions
issue-label-bot[bot]commented, Nov 3, 2019

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.54. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

3reactions
FerLuisxdcommented, May 7, 2022

still relevant 👍 , happened to me today

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node JSON output malforms, unable to set HTTP Header
I'm using a Node backend to (1) request API data from the Feedly Cloud, (2) output that data in JSON format and then...
Read more >
JsonResult Type in MVC - C# Corner
JsonResult is an ActionResult type in MVC. It helps to send the content in JavaScript Object Notation (JSON) format. History. To learn more ......
Read more >
OData JSON Format Version 4.01 - OASIS Open
This document defines representations for OData requests and responses using a JSON format.
Read more >
HTTP status and error codes for JSON | Cloud Storage
Cloud Storage uses the standard HTTP error reporting format for the JSON API. ... list the buckets for a project but do not...
Read more >
Free Automated Malware Analysis Service - powered by Falcon ...
CRC value set in PE header does not match actual value ... RTF_FILE, 0x601e8, 0x2e9, Rich Text Format data, version 1, ANSI, English....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found