Node.js: terminate HTTP connection

Show how to terminate an HTTP connection in Node.js

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


// OK: await-ing a Promise before sending an HTTP response
await Promise.resolve();

// WRONG: HTTP functions should send an
// HTTP response instead of returning.
return Promise.resolve();

// HTTP functions should signal termination by returning an HTTP response.
// This should not be done until all background tasks are complete.

// WRONG: this may not execute since an
// HTTP response has already been sent.
return Promise.resolve();

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.