Skip to content

Commit c2a582d

Browse files
fix(functions): remove redundant res.end (#4489)
* Fix HTTP response handling in httpTermination Updated HTTP response handling in httpTermination function to ensure proper termination signaling. * fix(functions): remove redundant res.end * fix(functions): remove redundant res.end * chore: fix lint errors --------- Co-authored-by: Angel Caamal <acaamalcanul@google.com>
1 parent 44511eb commit c2a582d

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

  • functions/concepts/httpTermination

‎functions/concepts/httpTermination/index.js‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
1514
'use strict';
16-
1715
/* eslint-disable no-unused-vars, no-unreachable */
18-
1916
const functions = require('@google-cloud/functions-framework');
20-
2117
functions.http('httpTermination', async (req, res) => {
2218
// [START functions_concepts_node_termination_http]
2319
// OK: await-ing a Promise before sending an HTTP response
@@ -29,8 +25,7 @@ functions.http('httpTermination', async (req, res) => {
2925

3026
// HTTP functions should signal termination by returning an HTTP response.
3127
// This should not be done until all background tasks are complete.
32-
res.send(200);
33-
res.end();
28+
res.status(200).send();
3429

3530
// WRONG: this may not execute since an
3631
// HTTP response has already been sent.

0 commit comments

Comments
 (0)