Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

BadRequestError: request aborted // Shopify 499 #86

Open
BarryCarlyon opened this issue Jun 4, 2018 · 2 comments
Open

BadRequestError: request aborted // Shopify 499 #86

BarryCarlyon opened this issue Jun 4, 2018 · 2 comments

Comments

@BarryCarlyon
Copy link

BarryCarlyon commented Jun 4, 2018

Shopify Webhook into Nginx -> proxy_pass to nodeJS

"POST /webhook/shop_update HTTP/1.1" 499 0 "-" "Ruby"

And catching the error:

{ BadRequestError: request aborted
    at IncomingMessage.onAborted (MYAPP/node_modules/raw-body/index.js:231:10)
    at IncomingMessage.emit (events.js:182:13)
    at abortIncoming (_http_server.js:444:9)
    at socketOnEnd (_http_server.js:460:5)
    at Socket.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1090:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

I believe this issue stream-utils/raw-body#57 is the "problem"

Likely down to my globalisation of bodyParser.json in error

app.use(bodyParser.json());

But probably worth to be able to support/handle bodyParser.jsonbeing globalised?

In my example, 90% of the routes in my application expect a JSON to be POST/PUT'ed so yes I globalised

@janfabian
Copy link

janfabian commented Jun 28, 2018

👍 I confirm this issue

my current solution

let json = require('body-parser').json();
json.unless = require('express-unless');
let middleware = [
    json.unless({ path: /\/webhooks*/ })
    // ...
]

@Mnabawy
Copy link

Mnabawy commented Sep 21, 2020

this issue is related to the body-parser package setup

`
// parse application/json
app.use(bodyParser.json())

app.use(function (req, res) {
res.setHeader('Content-Type', 'text/plain')
res.write('you posted:\n')
res.end(JSON.stringify(req.body, null, 2))
})
`

adding a generic JSON and URL-encoded

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants