Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Elaborate on async stack trace warning #340

Merged
merged 7 commits into from
Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/agent/debuglet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import * as _ from 'lodash';
import * as path from 'path';
import * as semver from 'semver';
import * as util from 'util';
import * as utils from './util/utils';
import * as http from 'http';

import {Controller} from './controller';
Expand Down Expand Up @@ -206,6 +207,13 @@ export class Debuglet extends EventEmitter {
*/
async start(): Promise<void> {
const that = this;
process.on('warning', (warning) => {
if ((warning as any).code ===
'INSPECTOR_ASYNC_STACK_TRACES_NOT_AVAILABLE') {
that.logger_.info(utils.messages.ASYNC_TRACES_WARNING);
}
});

const stat = promisify(fs.stat);

try {
Expand Down
5 changes: 4 additions & 1 deletion src/agent/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const messages = {
CAPTURE_BREAKPOINT_DATA: 'Error trying to capture snapshot data: ',
INVALID_LINE_NUMBER: 'Invalid snapshot position: ',
COULD_NOT_FIND_OUTPUT_FILE:
'Could not determine the output file associated with the transpiled input file'
'Could not determine the output file associated with the transpiled input file',
ASYNC_TRACES_WARNING: 'The Stackdriver debug agent does not use Inspector ' +

This comment was marked as spam.

This comment was marked as spam.

'async stack traces. The INSPECTOR_ASYNC_STACK_TRACES_NOT_AVAILABLE ' +
'warning does not impact Stackdriver debug agent and can be ignored.'
};

export interface Listener {
Expand Down
54 changes: 50 additions & 4 deletions test/test-debuglet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import * as stackdriver from '../src/types/stackdriver';
import {DebugAgentConfig} from '../src/agent/config';
import {Debuggee} from '../src/debuggee';
import * as semver from 'semver';

import * as _ from 'lodash';
import * as path from 'path';
Expand All @@ -29,6 +30,7 @@ import * as dns from 'dns';
import * as extend from 'extend';
const metadata: {project: any, instance: any} = require('gcp-metadata');
import {Debug} from '../src/client/stackdriver/debug';
import * as utils from '../src/agent/util/utils'

const DEBUGGEE_ID = 'bar';
const API = 'https://clouddebugger.googleapis.com';
Expand Down Expand Up @@ -289,16 +291,26 @@ describe('Debuglet', function() {
});

describe('setup', function() {
before(function() { oldGP = process.env.GCLOUD_PROJECT; });
before(function() {
oldGP = process.env.GCLOUD_PROJECT;
});

after(function() { process.env.GCLOUD_PROJECT = oldGP; });

beforeEach(function() {
let logText = '';
let oldLog: any;
beforeEach(() => {

This comment was marked as spam.

This comment was marked as spam.

delete process.env.GCLOUD_PROJECT;
oldLog = console.log;

This comment was marked as spam.

console.log = function(s: string) {
logText += s;
}
nocks.oauth2();
});

afterEach(function() { nock.cleanAll(); });
afterEach(() => {

This comment was marked as spam.

This comment was marked as spam.

console.log = oldLog;
nock.cleanAll();
});

it('should merge config correctly', function() {
const testValue = 2 * defaultConfig.capture.maxExpandFrames;
Expand All @@ -315,6 +327,40 @@ describe('Debuglet', function() {
assert.deepEqual(mergedConfig, compareConfig);
});

it('should elaborate on inspector warning on 32 bit but not on 64 bit',
function(done) {
const projectId = '11020304f2934-a';
const debug = new Debug(
{projectId: projectId, credentials: fakeCredentials});
const debuglet = new Debuglet(debug, defaultConfig);
let logText = '';
debuglet.logger_.info = function(s: string) {
logText += s;
};
nocks.projectId('project-via-metadata');
const scope = nock(API)
.post(REGISTER_PATH)
.reply(200, {debuggee: {id: DEBUGGEE_ID}});

debuglet.once('registered', function(id: string) {
assert.equal(id, DEBUGGEE_ID);
// TODO: Handle the case where debuglet.debuggee is undefined
assert.equal((debuglet.debuggee_ as Debuggee).project, projectId);
const arch = process.arch;
if (semver.satisfies(process.version, '>=8') &&

This comment was marked as spam.

(arch === 'ia32' || arch === 'x86')) {
assert(logText.includes(utils.messages.ASYNC_TRACES_WARNING));
} else {
assert(!logText.includes(utils.messages.ASYNC_TRACES_WARNING));
}
debuglet.stop();
scope.done();
done();
});

debuglet.start();
});

it('should not start when projectId is not available', function(done) {
const savedGetProjectId = Debuglet.getProjectId;
Debuglet.getProjectId = () => {
Expand Down