Page MenuHomePhabricator

preq provides no useful diagnostic info with 504 internal_http_error
Closed, ResolvedPublic

Description

When preq hits an error, it throws a very generic 504 with no useful diagnostic information:

{
  status: 504,
  type: "internal_http_error",
  detail: "504: internal_http_error",
  method: "post",
  uri: "https://en.wikipedia.org/w/api.php"
}

Log output is similarly unenlightening:

{
  "name":"service-mobileapp-node",
  "hostname":"mholloway",
  "pid":5548,
  "level":50,
  "message":"504: internal_http_error",
  "status":504,
  "type":"internal_http_error",
  "detail":"504: internal_http_error",
  "request_id":"cecc4f80-8961-11e9-bad7-bfcdf067ec2d",
  "request": {
    "url":"/en.wikipedia.org/v1/page/mobile-sections/Foobar",
    "headers":{
      "user-agent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0",
      "x-request-id":"cecc4f80-8961-11e9-bad7-bfcdf067ec2d"
    },
    "method":"GET",
    "params":{
      "0":"/en.wikipedia.org/v1/page/mobile-sections/Foobar"
    },
    "query":{},
    "remoteAddress":"127.0.0.1",
    "remotePort":47034
  },
  "levelPath":"error/504",
  "msg":"504: internal_http_error",
  "time":"2019-06-07T20:21:18.595Z",
  "v":0
}

Actually, it appears that error details are being stripped in favor of a redundant message that just restates the status code and type. Removing these lines results in the underlying error message being passed through, which is much more helpful:

{
  status: 504
  type: "internal_http_error"
  detail: "Error: unable to get local issuer certificate"
  method: "post"
  uri: "https://en.wikipedia.org/w/api.php" 
}

It looks like a stack trace is also being captured, but not passed through for reasons that aren't clear to me.

Event Timeline

mobrovac subscribed.

This is the fault of the error-handling code in the service template. PR #122 should fix this.

This is the fault of the error-handling code in the service template. PR #122 should fix this.

It turns out it's also the fault of preq :P PR #45 improves the error message.

preq v0.5.9 provides better error-message handling in the case of retries (504s). Resolving.