ijpiantanida / talkback

A simple HTTP proxy that records and playbacks requests
MIT License
284 stars 41 forks source link

SyntaxError when trying to record a GET request with no body #16

Closed mj12albert closed 5 years ago

mj12albert commented 5 years ago

Getting this error when trying to record a get request with no body

Error handing request SyntaxError: Unexpected end of JSON input
    at JSON.parse
    at Tape.normalizeBody
    at new Tape

I think its from here? https://github.com/ijpiantanida/talkback/blob/master/src/tape.js#L69

JSON.parse error when this.req.body is undefined

ijpiantanida commented 5 years ago

Is this from the incoming request, or from a saved tape?

Incoming requests always have at least an empty body (https://github.com/ijpiantanida/talkback/blob/master/src/server.js#L22)

And tapes are expected to always have the body property, at least set to an empty string.

mj12albert commented 5 years ago

I see, this is from the incoming request. (trying to save a tape)

so it must be something wrong with the data in the response body... 🤔

ijpiantanida commented 5 years ago

Hi @mj12albert. It turns out there was a problem with empty requests after all.

I just published v1.8.1 with a fix.