Cloud Functions 函数概念:函数终止

发出信号来终止节点中的函数

深入探索

如需查看包含此代码示例的详细文档,请参阅以下内容:

代码示例

Node.js

// Await-ing promises within functions is OK if you don't return anything
await Promise.resolve();

// These will cause background tasks to stop executing immediately
return 1; // OK: returning a value
return await Promise.resolve(); // WRONG: returning the result of a promise
return await Promise.reject(); // WRONG: same behavior as resolved promises

// These will wait until the related background task finishes
return Promise.resolve(); // OK: returning the promise itself
return Promise.reject(); // OK: same behavior as to-be-resolved promises

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器