How to use the node-abort-controller function in node-abort-controller

To help you get started, we’ve selected a few node-abort-controller examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / cosmosdb / cosmos / src / request / RequestHandler.ts View on Github external
async function httpRequest(requestContext: RequestContext) {
  const controller = new AbortController();
  const signal = controller.signal;

  // Wrap users passed abort events and call our own internal abort()
  const userSignal = requestContext.options && requestContext.options.abortSignal;
  if (userSignal) {
    if (userSignal) {
      controller.abort();
    } else {
      userSignal.addEventListener("abort", () => {
        controller.abort();
      });
    }
  }

  const timeout = setTimeout(() => {
    controller.abort();

node-abort-controller

AbortController for Node based on EventEmitter

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis

Popular node-abort-controller functions