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

Commit 1d300ac

Browse files
chore: Update Readme to include isReady interface (#368)
1 parent 248eda1 commit 1d300ac

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ process.env['GCLOUD_USE_INSPECTOR'] = true;
189189
require('@google-cloud/debug-agent').start({ ... });
190190
```
191191

192+
## Using Stackdriver Debugger on Google Cloud Functions
193+
194+
The Stackdriver Debugger also introduces a new `isReady` method that returns a `Promise` that is resolved in either of the three scenarios.
195+
1. The debug agent has received snapshot information from the Stackdriver service.
196+
2. The last snapshot received from Stackdriver service is relatively recent.
197+
3. The debug agent has determined that it is not possible to receive snapshot information.
198+
199+
In order for Stackdriver Debugger to work on GCF, users should call the `isReady` function and wait for the returned `Promise` to resolve before exiting the cloud function. The purpose of this is to allow the Debug Agent enough time to sync reasonably up-to-date snapshot information; in most cases this is instantaneous and the worst (rare) case is to delay up to 40 seconds.
200+
201+
```js
202+
const debug = require('@google-cloud/debug-agent').start();
203+
exports.myFunc = (event) => {
204+
const debugReady = debug.isReady();
205+
debugReady.then(() => {
206+
// ...
207+
});
208+
}
209+
```
210+
192211
## Limitations and Requirements
193212
* The root directory of your application needs to contain a `package.json` file.
194213
* You can set snapshot conditions and watch expressions to be evaluated in the context of your application. This leads to some issues you should be aware of

0 commit comments

Comments
 (0)