Giter Club home page Giter Club logo

cloud-debug-nodejs's Introduction

Google Cloud Platform logo

release level npm version

This module provides Snapshot Debugger support for Node.js applications. Snapshot Debugger is an open source product that lets you debug your applications in production without stopping or pausing your application.

A Firebase Realtime Database instance is used to store your data.

Project Status: Archived

This project has been archived and is no longer supported. There will be no further bug fixes or security patches. The repository can be forked by users if they want to maintain it going forward.

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable the Cloud Debugger API.
  3. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/debug-agent

Debugger Agent Settings

To customize the behaviour of the automatic debugger agent, specify options when starting the agent. The following code sample shows how to pass in a subset of the available options.

require('@google-cloud/debug-agent').start({
  // .. auth settings ..

  // debug agent settings:
  allowExpressions: true,
  serviceContext: {
    service: 'my-service',
    version: 'version-1'
  },
  capture: { maxFrames: 20, maxProperties: 100 }
});

The following options configure the connection to the Firebase database:

  • firebaseDbUrl - https://PROJECT_ID-cdbg.firebaseio.com will be used if not provided. where PROJECT_ID is your project ID.
  • firebaseKeyPath - Default google application credentials are used if not provided.

Some key configuration options are:

  • allowExpressions - Whether or not it is permitted to evaluate epressions. Functionality is limited when this is not set, but there is some risk that malicious expressions can mutate program state.
  • serviceContext - This information is utilized in the UI to identify all the running instances of your service. Set this if you do not like the default values.
  • capture - Configuration options on what is captured on a snapshot. Set this if the default snapshot captures are too limited. Note that relaxing constraints may cause performance impact.

See the agent configuration for a list of possible configuration options.

Using the Debugger

Once your application is running, use the Snapshot Debugger CLI or the VSCode extension to debug your application.

Historical note

Version 6.x and 7.x of this agent supported both the now shutdown Cloud Debugger service (by default) and the Snapshot Debugger (Firebase RTDB backend) by setting the useFirebase flag to true. Version 8.0.0 removed support for the Cloud Debugger service, making the Snapshot Debugger the default. To note the useFirebase flag is now obsolete, but still present for backward compatibility.

Limitations and Requirements

Note: There is a known issue where enabling the agent may trigger memory leaks. See #811

  • Privacy issues can be created by setting snapshot conditions that watch expressions evaluated in the context of your application. You may be able to view sensitive user data when viewing the values of variables.
  • The debug agent tries to ensure that all conditions and watchpoints you add are read-only and have no side effects. It catches, and disallows, all expressions that may have static side effects to prevent accidental state change. However, it presently does not catch expressions that have dynamic side-effects. For example, o.f looks like a property access, but dynamically, it may end up calling a getter function. We presently do NOT detect such dynamic-side effects.
  • The root directory of your application needs to contain a package.json file.

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

Sample Source Code Try it
App source code Open in Cloud Shell
Snippets source code Open in Cloud Shell

The Cloud Debugger Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.

Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/debug-agent@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE

cloud-debug-nodejs's People

Contributors

alexander-fenster avatar avaksman avatar bcoe avatar cristiancavalli avatar dominickramer avatar dpebot avatar eyqs avatar fhinkel avatar gaofanmichael avatar gcf-merge-on-green[bot] avatar gcf-owl-bot[bot] avatar google-cloud-policy-bot[bot] avatar greenkeeper[bot] avatar jasonborg avatar jkwlui avatar justinbeckwith avatar kjin avatar louis-ye avatar matthewloring avatar mctavish avatar ofrobots avatar release-please[bot] avatar renovate-bot avatar renovate[bot] avatar sofisl avatar soldair avatar summer-ji-eng avatar surferjeffatgoogle avatar theacodes avatar yoshi-automation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloud-debug-nodejs's Issues

TypeScript support

This is related to ES6 support and Better support transpiled JavaScript but I thought that keeping the TypeScript bits separate might be helpful.

I'm trying to use cloud-debug with TypeScript using the instructions here. But I figured that I should keep the discussions separated.

We're running in the GAE Flexible Environment with the default NodeJS Runtime.

I'm seeing Only files with .js extensions or source maps are supported in the Debug UI when setting a breakpoint in my .ts files.

Here's my tsconfig.json:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "declaration": false,
    "noImplicitAny": false,
    "removeComments": false,
    "preserveConstEnums": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "outDir": "dist"
  },
  "exclude": [
    "node_modules",
    "typings",
    "coverage"
  ]
}

We had to add the following to our typings.d.ts file in our root dir:


declare module 'request-promise' {
  function requestPromise(options: any): Promise<any>;
  export = requestPromise;
}
declare module 'xml2js' {
  function parseString(xml: string, callback: Function): void;
}
declare module 'google-cloud' {
  import {Readable, Writable} from 'stream';
  class Storage {
    bucket (name: string): StorageBucket;
  }
  class StorageBucket {
    file (name: string): StorageFile;
    getFiles (options: Object, callback: Function): void;
  }
  class StorageFile {
    createReadStream (): Readable;
    createWriteStream (options: any): Writable;
    delete(callback: Function): void;
  }
  class PubSub {
    topic (name: string) : Topic;
    subscription (name: string): any;
    createTopic (name: string, callback: Function): void;
    getTopics (callback: Function): void;
  }
  class Topic {
    publish (message: Object, callback: Function): void;
    subscribe (subscriptionName: string, options: Object, callback: Function): void;
    delete (callback: Function): void;
  }
  class Subscription {
    pull (options: Object, callback: Function): void;
    on (listenerType: string, callback: Function): void;
    removeListener (listenerType: string, Function): void;
  }
  class BigQuery {
    createDataset(id: string, callback: Function): void;
    dataset(id: string): Dataset;
    getDatasets(query: Object, callback: Function): void;
  }
  class Dataset {
    table(id: string): Table;
    exists(callback: Function): void;
    create(callback: Function): void;
  }
  class Table {
    insert(rows: Object, options: Object, callback: Function): void;
  }
  class GCloud {
    storage (options: any): Storage;
  }
  function gcloud (options: any): GCloud;
  function bigquery (options?: any): BigQuery;
  function storage (options?: any): Storage;
  function pubsub (options?: any): PubSub;
}

All .ts files are in source control and the generated .js and .js.map files are located in dist/ which is where npm start runs via tsc && node dist/index.js. The dist/ dir is not in source control but it does exist in the running container.

I tried to use import * as debug from '@google/cloud-debug' as mentioned in the guide, but that gave unknown module errors. So we're just using the following (which remains the same after transpilation):

require('@google/cloud-trace').start();
require('@google/cloud-debug');

Add docs explaining source map requirements

Its a bit unclear from the documentation whether or not the application sources actually need to exist on disk within the runtime environment or whether cloud debug uses the remote sources (GCP repo, GH, BitBucket, etc) for resolving references.

For example, given the following source directory structure:

.
├── package.json
├── node_modules
├── src
│   ├── client
│   ├── components
│   ├── server
│   │   └── index.js
│   ├── etc...

and resulting build artifacts:

.
├── app
│   ├── package.json
│   ├── source-context.json
│   ├── source-contexts.json
│   ├── node_modules
│   ├── server
│   │   ├── main.js
│   │   └── main.js.map **
│   ├── etc...

Will debug be able to resolve references to source mapped sources (e.g., ./src/components/Foo/index.js) or would the sources need to exist within the runtime environment?

** all individual application sources are bundled within /app/server/main.js with references to ./src/components/Foo/index.js within /app/server/main.js.map

No debugger available on App Engine flex

My app.js contains require('@google/cloud-debug');
I deployed my Node.js app on App Engine flexible.

The debug view says:
The Cloud Debugger could not find any application to debug:
Discovering debuggable applications

The README says:
"If you are using Google App Engine Managed VMs, you do not have to do any additional configuration."

Why isn't the Cloud Debugger available?

Greatly increased error logging over the last few days

We've been using this library for a few weeks now ("@google/cloud-debug": "0.8.4") and we've occasionally seen some errors about failing to make a connection, but those have generally been a few per day. As of 9/28 or so, we're seeing the following message once per minute:

ERROR:@google/cloud-debug: Failed to re-register debuggee: Error: getaddrinfo ENOTFOUND clouddebugger.googleapis.com clouddebugger.googleapis.com:443

We've also been seeing this message a lot:

 "ERROR:@google/cloud-debug: Unable to fetch breakpoints – stopping fetcher { [Error: getaddrinfo ENOTFOUND clouddebugger.googleapis.com clouddebugger.googleapis.com:443]"

Also around 3am-9am today and 5:23pm-11pm on 9/29, we were seeing this message once per minute:

"ERROR:@google/cloud-debug: Failed to re-register debuggee: Error: getaddrinfo ENOTFOUND accounts.google.com accounts.google.com:443"

We also saw this message just once on 9/29:

"ERROR:@google/cloud-debug: Unable to fetch breakpoints – stopping fetcher [Error: unable to list breakpoints, status code 401]"

On 9/28, we were seeing, but only a few times per day:

 "ERROR:@google/cloud-debug: Unable to fetch breakpoints – stopping fetcher [Error: unable to list breakpoints, status code 504]"

We have the ENV var defined for GCLOUD_PROJECT=<our project name>. We also have a JSON service account key which is pointed to by GOOGLE_APPLICATION_CREDENTIALS=<path>. We also have our require('@google/cloud-debug'); statement at the top of our index.ts/js.

Finally, our NodeJS project is in TypeScript, so we've never been able to get the debugger to work yet. Is the guidance that we source control our transpiled ES5 source code? Are there any guides for using TypeScript with Cloud Debug and NodeJS?

Thank you!

Any insight on this forbidden error, seems related to Compute Engine permissions?

Environment/Infrastructure: Kubernetes 1.4.7 cluster deployed on GCP.

I'm not quite sure where to start with this, feels like all of the authentication is in place and the project is properly configured but I'm not able to get any of the logging out. It's not even spitting out the default stuff that I see locally.

Looking at the pod that has the NodeJs application deployed, seeing lots of this:

Failed to re-register debuggee 413636282855: Error: A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified. Request had insufficient authentication scopes.

Note that this is my configuration at the cluster level:

resources:
- name: dev-kube
  type: container.v1.cluster
  properties:
    zone: us-central1-a
    cluster:
      description:  Web Application DEV Cluster
      nodePools:
        - name: dev-web
          initialNodeCount: 1
          autoscaling: 
            enabled: true
            minNodeCount: 1
            maxNodeCount: 5
          config:
            machineType: n1-standard-1
            diskSizeGb: 100
            serviceAccount: default
            labels:
              env: dev
      loggingService: logging.googleapis.com
      monitoringService: monitoring.googleapis.com
      network: default
      addonsConfig:
          horizontalPodAutoscaling:
            disabled: false
      network: default

Node crash when agent is concurrently enabled with inspect

GCLOUD_USE_INSPECTOR=1 node --inspect log.js

Where log.js is a simple express app with this at the top:

const debug = require('@google-cloud/debug-agent').start({
  projectId: 'some project id'
});

Node crashes when DevTools connects.

/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node[32991]: ../src/inspector_agent.cc:346:void node::inspector::NodeInspectorClient::connectFrontend(node::inspector::InspectorSessionDelegate*): Assertion `(channel_) == (nullptr)' failed.
 1: node::Abort() [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
 2: node::(anonymous namespace)::DomainEnter(node::Environment*, v8::Local<v8::Object>) [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
 3: node::inspector::NodeInspectorClient::FatalException(v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
 4: node::inspector::InspectorIo::DispatchMessages() [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
 5: node::RunForegroundTask(v8::Task*) [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
 6: node::NodePlatform::FlushForegroundTasksInternal() [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
 7: uv__async_io [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
 8: uv__io_poll [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
 9: uv_run [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
10: node::Start(v8::Isolate*, node::IsolateData*, int, char const* const*, int, char const* const*) [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
11: node::Start(uv_loop_s*, int, char const* const*, int, char const* const*) [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
12: node::Start(int, char**) [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]
13: start [/Users/ofrobots/.nvm/versions/node/v8.9.0/bin/node]

Gracefully handle unexpected source maps

When encountering a source map that the agent doesn't expect (e.g., a css source map), the agent seem to fail to initialize. Here's a sample log entry:

ERROR:@google-cloud/debug-agent: Error processing the sourcemaps. Error: An error occurred while processing the sourcemap filesError: No sources listed in the sourcemap file public/vi-assets/main-b7c14129f872a062abe21d8edb364c0d.css.map

Invalid value at breakpoints using GKE.

I get the following in my logs using the node cloud debugger in Kubernetes on GKE, I have the cloud platform enabled for the cluster.

This occurs after I set a breakpoint in the application, and then hit that piece of code.

[ { message: 'Invalid value at \'breakpoint.variable_table[10].members[1].name\' (TYPE_STRING), 0\nInvalid value at \'breakpoint.variable_table[10].members[2].name\' (TYPE_STRING), 1\nInvalid value at \'breakpoint.variable_table[10].members[3].name\' (TYPE_STRING), 2\nInvalid value at \'breakpoint.variable_table[10].members[4].name\' (TYPE_STRING), 3\nInvalid value at \'breakpoint.variable_table[10].members[5].name\' (TYPE_STRING), 4\nInvalid value at \'breakpoint.variable_table[10].members[6].name\' (TYPE_STRING), 5\nInvalid value at \'breakpoint.variable_table[10].members[7].name\' (TYPE_STRING), 6\nInvalid value at \'breakpoint.variable_table[10].members[8].name\' (TYPE_STRING), 7\nInvalid value at \'breakpoint.variable_table[10].members[9].name\' (TYPE_STRING), 8\nInvalid value at \'breakpoint.variable_table[10].members[10].name\' (TYPE_STRING), 9\nInvalid value at \'breakpoint.variable_table[10].members[11].name\' (TYPE_STRING), 10\nInvalid value at \'breakpoint.variable_table[10].members[12].name\' (TYPE_STRING), 11\nInvalid value at \'breakpoint.variable_table[10].members[13].name\' (TYPE_STRING), 12\nInvalid value at \'breakpoint.variable_table[10].members[14].name\' (TYPE_STRING), 13\nInvalid value at \'breakpoint.variable_table[10].members[15].name\' (TYPE_STRING), 14\nInvalid value at \'breakpoint.variable_table[10].members[16].name\' (TYPE_STRING), 15\nInvalid value at \'breakpoint.variable_table[10].members[17].name\' (TYPE_STRING), 16\nInvalid value at \'breakpoint.variable_table[10].members[18].name\' (TYPE_STRING), 17\nInvalid value at \'breakpoint.variable_table[10].members[19].name\' (TYPE_STRING), 18\nInvalid value at \'breakpoint.variable_table[10].members[20].name\' (TYPE_STRING), 19\nInvalid value at \'breakpoint.variable_table[10].members[21].name\' (TYPE_STRING), 20\nInvalid value at \'breakpoint.variable_table[10].members[22].name\' (TYPE_STRING), 21\nInvalid value at \'breakpoint.variable_table[10].members[23].name\' (TYPE_STRING), 22\nInvalid value at \'breakpoint.variable_table[10].members[24].name\' (TYPE_STRING), 23',

Node.js apps that are sub-directories of the git repository don't work.

Scenario:

  1. Git repository with a directory Server/ that contains a Node.js app. i.e. Server/app.js and Server/app.yaml exist.
  2. Host the repository in a gcloud source repo.
  3. Deploy the app, or copy Server/* to /tmp/app and run it locally from there.

Once deployed the path to app.js is /app/app.js. But to the Debug UI, this is Server/app.js.

Immediate goal: in this scenario we should be able to set a breakpoint in app.js without being confused.

Secondary goal: consider the following directory layout:
Server/app.js -> /app/app.js
Server/foo/app.js-> /app/foo/app.js
Server/app/app.js -> /app/app/app.js

In such an app, we should be able to set the breakpoint in the correct app.js when the server sets a breakpoint in Server/app.js, Server/app/app.js. We should report an error when the server asks for a breakpoint in app.js. We need test cases for these scenario.

Improve validation of API messages

#98 implements hand-rolled validations in tests to ensure our breakpoint messages are not going to rejected by the API due to type errors. Going forward this should be improved in two ways:

  • Validate against the original protobuf instead of hand-rolling the messages
  • Perform validation in lib instead of tests.

Add a test w/ Node 0.10

We do not support the 0.10, but we should report an error to the UI when a breakpoint is set.

Wrong types

I'm using Node with TypeScript and I'm facing an issue with types when starting the debugger as suggested in the Quick Start section:

import debugAgent = require('@google-cloud/debug-agent');
debugAgent.start({ allowExpressions: true });

It seems the type definition is wrong and more params (other than allowExpressions) are required:

Argument of type '{ allowExpressions: true; }' is not assignable to parameter of type 'DebugAgentConfig | StackdriverConfig'.

Let users provide Project Id via GOOGLE_APPLICATION_CREDENTIALS

Today in cloudcats I am providing the ProjectId via the PROJECT_ID env var. I also have to provide a keyfile, which I was passing into the code. In an effort to make things a little more smooth on the config side, I tried to use GOOGLE_APPLICATION_CREDENTIALS instead of defining PROJECT_ID and the keyfile. The projectId is inside of my keyfile - but we still seem to require the ProjectId along with the key file :(

beckwith-macbookpro:web beckwith$ npm start

> [email protected] start /Users/beckwith/Code/cloudcats/web
> GOOGLE_APPLICATION_CREDENTIALS=keyfile.json node server.js

info: Server running at: http://0.0.0.0:8080
ERROR:@google-cloud/trace-agent: Unable to acquire the project number from metadata service. Please provide a valid project number as an env. variable, or through config.projectId passed to start(). Error: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80
ERROR:@google-cloud/debug-agent: The project ID could not be determined: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80

Can we just read the projectId from the keyfile?

'Unable to initialize the debuglet api -- disabling debuglet' should not crash

ERROR:@google/cloud-debug: Unable to initialize the debuglet api -- disabling debuglet [Error: Could not auto-discover project-id. Please export GCLOUD_PROJECT with your project name]

I am not sure this should be crashing my app.

I am developing locally, I have no intent to use the Debugger here.
I should be able to develop without needing to set GCLOUD_PROJECT with my project name.

debug agent fails to activate without a useful error message

On my simple app, I had:

const debug = require('@google-cloud/debug-agent').start();
❯ node log.js
ERROR:@google-cloud/debug-agent: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80
^C

❯ GCLOUD_DEBUG_LOGLEVEL=4 node log.js
INFO:@google-cloud/debug-agent: activating v8 breakpoint listener (permanent)
INFO:@google-cloud/debug-agent: Unique ID for this Application: SHA1-c9f5b63f91648d636b156d1d6a92e6b527c28e62
ERROR:@google-cloud/debug-agent: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80

The debug agent did not work. With the following change to my source the debugger started working:

const debug = require('@google-cloud/debug-agent').start({
  projectId: 'my real project id'
});

So the lack of the project id was a problem, but the error message was unhelpful.

Failed to re-register debuggee XXX: ApiError: Precondition check failed.

GAE Flex NodeJS

"node": ">6.4.0"

require('@google-cloud/debug-agent').start({ allowExpressions: true });
after the trace-agent requre.

I get an error:
ERROR:@google-cloud/debug-agent: Failed to re-register debuggee project-name-redacted: ApiError: Precondition check failed.

mod-edit: redacted project name.

vscode and node 8.8.1+ interaction

I've found that when we moved our service from node v6.11.1 to v8.8.1 or v8.9.0 we can no longer debug our service locally if we include the debug-agent (vscode stops hitting breakpoints). When I comment out the line

// require('@google-cloud/debug-agent').start({ allowExpressions: true })

our service can be debugged locally and vscode can once again hit breakpoints

Configuration options?

I am seeing this error in my App Engine project:

(Locals and arguments are only displayed for the top `config.capture.maxExpandFrames` stack frames.

Is this expected? How do I configure these options?

Off-by-one-line error in transpiled breakpoint

app.ts

import * as debug from '@google/cloud-debug'
import * as express from 'express';
var app = express();
app.get('/', (req, res) => {
  res.status(200).send(`express + ${debug}`);
});
app.get('/hello/:name', (req, res) => {
  var msg : string = `Hello ${req.params.name}`;
  res.status(200).send(msg);
});

app.listen(process.env.PORT || 8080, function() {
  console.log('App started');
});

export var App = app;

Compile with tsc --sourceMap app.ts, producing app.js:

"use strict";
var debug = require('@google/cloud-debug');
var express = require('express');
var app = express();
app.get('/', function (req, res) {
    res.status(200).send("express + " + debug);
});
app.get('/hello/:name', function (req, res) {
    var msg = "Hello " + req.params.name;
    res.status(200).send(msg);
});
app.listen(process.env.PORT || 8080, function () {
    console.log('App started');
});
exports.App = app;
//# sourceMappingURL=app.js.map

Set breakpoint at app.ts:9. This corresponds to app.js:10. We, however, resolve this to app.js:9. msg is undefined.

screen shot 2016-10-02 at 1 10 36 pm

CoffeeScript error messages don't make sense

The following is the output from the 'should capture without values for invalid watch expressions in compiled code' test (if the log level is changed to INFO):

ERROR:: Unable to compile break or watch point >> :) << { [SyntaxError: unmatched )]
  location: { first_line: 0, first_column: 8, last_column: 8 },
  toString: [Function],
  code: '0 || (:))',
  filename: undefined }
ERROR:: Unable to compile break or watch point >> process=this << [TypeError: Cannot read property '1' of null]
ERROR:: Unable to compile break or watch point >> ((x) -> x x) n << [TypeError: Cannot read property '1' of null]
ERROR:: Unable to compile break or watch point >> return << { [SyntaxError: cannot use a pure statement in an expression]
  location: { first_line: 0, first_column: 6, last_line: 0, last_column: 11 },
  toString: [Function],
  code: '0 || (return)',
  filename: undefined }
      ✓ should capture without values for invalid watch expressions in compiled code (207ms)

Apart from the first error, the remainder aren't very useful, but then again, I don't know CoffeeScript. We should look into these to make sure they make sense to CoffeeScripters.

SourceMapper should support input paths being suffixes of on-disk paths

While moving the repo structure I ran into the a test failure with test-v8debugapi.js. The test is trying to set a breakpoint in test/fixtures/coffee/transpile.coffee. Sourcemapper fails to find the corresponding output file / map file for this file because it has the following map:

MapIterator {
  'packages/debug/test/fixtures/es6/transpile.es6',
  'packages/debug/test/fixtures/coffee/transpile.coffee',
  'packages/debug/test/fixtures/sourcemapper/babel/in.js',
  'packages/debug/test/fixtures/sourcemapper/typescript/in.ts',
  'packages/debug/test/fixtures/sourcemapper/coffeescript/in.coffee' }

The test fails with:

  1) v8debugapi set and wait should be possible to set conditional breakpoints in coffeescript:
     Uncaught Error: Could not determine the output file associated with the transpiled input file
      at setErrorStatusAndCallback (packages/debug/src/agent/v8debugapi.js:557:17)
      at Object.set (packages/debug/src/agent/v8debugapi.js:125:18)
      at Context.<anonymous> (packages/debug/test/test-v8debugapi.js:984:13)

This is because test/fixtures/coffee/transpile.coffee does not exist in the map above exactly.

For non-transpiled files we are quite flexible in being to find the files even if the repo structure doesn't end up matching the deployed / under-debug version of the files. We need a similar treatment here.

GKE: Error scanning the filesystem

When I start the debug agent on GCP GKE I have the following error:

ERROR:@google-cloud/debug-agent: Error scanning the filesystem. Error: ENOENT: no such file or directory, lstat '/proc/15/fd/11'

I'm not able to see the application on debug UI.

require('@google-cloud/debug-agent').start({
  allowExpressions: true,
  serviceContext: {
    service: 'service-sms',
  },
});

My cluster has the the cloud_debugger OAuth scope.

Docs: Better documentation for available configuration options

While directing users to the library's source code for available configuration options will arguably give them the source of truth, it is quite a jarring experience when users on https://cloud.google.com/debugger/docs/setup/nodejs are redirected to a .js file on GitHub.

Can we please add a table of available configuration options to the README?

OR

Can we please get some JSDoc reference docs (that include the available configuration options) published for this library?

Thanks

Support for es6

Only files with .js extensions or source maps are supported

Of course you do support es6 natively for nodejs now without source maps and without transpiling. But the cloud debug won't support them.

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.