Giter Club home page Giter Club logo

Comments (4)

jthomas avatar jthomas commented on May 29, 2024

I've been looking into surfacing HTTP traces to assist debugging issues. This library uses the request npm module as the HTTP client. I've discovered this library supports a configuration flag to dump HTTP traffic.

NODE_DEBUG=request node script.js

Here's an example of the output for the following code.

var ow = openwhisk({api_key: 'xxx:yyy', apihost: 'openwhisk.ng.bluemix.net', namespace: '[email protected]_dev'});

ow.actions.list().then(console.log).catch(console.log)
NODE_DEBUG=request node test.js
REQUEST { json: true,
  method: 'GET',
  url: 'https://openwhisk.ng.bluemix.net/api/v1/namespaces/james.thomas%40uk.ibm.com_dev/actions',
  rejectUnauthorized: true,
  headers: { Authorization: 'Basic xxxxxx=' },
  qs: {},
  callback: undefined,
  transform: undefined,
  simple: true,
  resolveWithFullResponse: false }
REQUEST make request https://openwhisk.ng.bluemix.net/api/v1/namespaces/james.thomas%40uk.ibm.com_dev/actions
REQUEST onRequestResponse https://openwhisk.ng.bluemix.net/api/v1/namespaces/james.thomas%40uk.ibm.com_dev/actions 200 { 'x-backside-transport': 'OK OK',
  connection: 'close',
  'transfer-encoding': 'chunked',
  server: 'nginx/1.11.10',
  date: 'Sat, 11 Mar 2017 08:48:07 GMT',
  'content-type': 'application/json; charset=UTF-8',
  'access-control-allow-origin': '*',
  'access-control-allow-headers': 'Authorization, Content-Type',
  'x-global-transaction-id': '3848629955',
  'set-cookie': [ 'DPJSESSIONID=xxxx; Path=/; Domain=.whisk.ng.bluemix.net' ] }
REQUEST reading response's body
REQUEST finish init function https://openwhisk.ng.bluemix.net/api/v1/namespaces/james.thomas%40uk.ibm.com_dev/actions
REQUEST response end https://openwhisk.ng.bluemix.net/api/v1/namespaces/james.thomas%40uk.ibm.com_dev/actions 200 { 'x-backside-transport': 'OK OK',
  connection: 'close',
  'transfer-encoding': 'chunked',
  server: 'nginx/1.11.10',
  date: 'Sat, 11 Mar 2017 08:48:07 GMT',
  'content-type': 'application/json; charset=UTF-8',
  'access-control-allow-origin': '*',
  'access-control-allow-headers': 'Authorization, Content-Type',
  'x-global-transaction-id': '3848629955',
  'set-cookie': [ 'DPJSESSIONID=xxxx; Path=/; Domain=.whisk.ng.bluemix.net' ] }
REQUEST end event https://openwhisk.ng.bluemix.net/api/v1/namespaces/james.thomas%40uk.ibm.com_dev/actions
REQUEST has body https://openwhisk.ng.bluemix.net/api/v1/namespaces/james.thomas%40uk.ibm.com_dev/actions 945
REQUEST emitting complete https://openwhisk.ng.bluemix.net/api/v1/namespaces/james.thomas%40uk.ibm.com_dev/actions

This looks like a good solution for helping to get HTTP traffic when encountering issues.
@rabbah & @starpit - what do you think? is this enough?

If we like this, I'll document it in the README.md as our solution.

from openwhisk-client-js.

starpit avatar starpit commented on May 29, 2024

For me, the main thing is being specific about failures. The cli has the same problem (and itself had open issues on this very point).

Right now, I neither get specifics about my failing request, nor (and worse, in my opinion) a helpful stack trace. The stack trace is blinded by some async intermediary.

With the proposal, I would... somehow have to re-execute my failing request? This won't help with prod failures. And, anyway, how does one inject an envvar in to a whisk-excuted action?

from openwhisk-client-js.

jthomas avatar jthomas commented on May 29, 2024

I've added information about this feature to the README.
https://github.com/openwhisk/openwhisk-client-js/blob/master/README.md#debugging

Turning this on at runtime can be done like....

process.env.NODE_DEBUG='request';
var openwhisk = require('openwhisk');

function main(params) {
  var ow = openwhisk();  

  return ow.actions.list().then(arr => ({result: arr}))
}

from openwhisk-client-js.

jthomas avatar jthomas commented on May 29, 2024

@starpit I agree that the error responses from the library could be more helpful but I think some of that is due to that platform responses.

I'm going to close this ticket as resolved and can we open another issue for error messages and discuss requirements?

from openwhisk-client-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.