简体   繁体   English

在Typescript中将Stackdriver调试器与云功能一起用于Firebase

[英]Use Stackdriver debugger with cloud functions for Firebase in Typescript

I want to connect the stackdriver debug agent in the cloud functions for firebase. 我想在Firebase的云函数中连接stackdriver debug agent。 The following is how I did set up the stackdriver agent to use on the start on the functions I want to debug. 以下是我设置堆栈驱动程序代理以在要调试的功能上使用的方式。

// For debugging purposes
const debug = require('@google-cloud/debug-agent').start({  allowExpressions: true,
});

export async function listen() {
     await debug.isReady();
}

Then use it like the following 然后像下面一样使用它

export async function exampleCallableWrapper(
  data: any,
  context: functions.https.CallableContext
) {
  await listen();
  data.Id = shortid.generate();
// Do something

  return 
}

I want to see the data object for example. 我想例如查看数据对象。 The snapshot doesn't show anything after putting the breakpoint. 放置断点后,快照不显示任何内容。

  • I did put the breakpoint in the original functions/src folder where the function is located. 我确实将断点放在函数所在的原始functions / src文件夹中。

  • I also tried to point it on the lib folder manually with no luck as I had to do it manually. 我也尝试手动将其指向lib文件夹,但是没有运气,因为我必须手动进行操作。

  • I did see the function start and return ok successfully with no problem but nothing to show in the stackdriver debugger page 我确实看到函数成功启动并成功返回ok,没有问题,但是在stackdriver debugger页面中没有任何显示

The versions of functions and stackdriver are as follows 函数和堆栈驱动程序的版本如下

"@google-cloud/debug-agent": "^3.0.0",

"firebase-functions": "^2.0.5",

This solution implement Stackdriver Debugger with Cloud Function. 解决方案使用Cloud Function实现Stackdriver Debugger。 It might be useful to review how they implement it versus your code. 回顾他们与代码相比如何实现它可能很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM