Skip to main content
Home

Exit event listeners for Deno

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
94%
Published
4 months ago (2.0.0)

OnExit

Exit event listeners for Deno. Listens for unload and unhandledrejection events.

Basic Usage

import { addExitListener } from "<import-path>";

addExitListener(event => console.debug(`Process exit detected\nCause: ${event?.cause}`));

Signals

By default, the exit event will not be dispatched when the process exits due to a signal (e.g. SIGINT, SIGTERM, SIGKILL, etc.). To enable this behavior, call the exitOnSignal function with the signals you want to listen for.

/**
 * Registers exit event listeners for the specified signals.
 *
 * @param {Deno.Signal[]} [signals=["SIGINT", "SIGTERM", "SIGQUIT"]] - The signals to listen for.
 * @param {boolean} [clear=true] - Whether to clear any previously registered signal listeners.
 */
import { exitOnSignal } from "<import-path>";

exitOnSignal(["SIGINT"]); // defaults to SIGINT, SIGTERM, SIGQUIT

Signal listeners can also be cleared by calling clearSignalListeners.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@zerm/onexit

Import symbol

import * as onexit from "@zerm/onexit";
or

Import directly with a jsr specifier

import * as onexit from "jsr:@zerm/onexit";

Add Package

pnpm i jsr:@zerm/onexit
or (using pnpm 10.8 or older)
pnpm dlx jsr add @zerm/onexit

Import symbol

import * as onexit from "@zerm/onexit";

Add Package

yarn add jsr:@zerm/onexit
or (using Yarn 4.8 or older)
yarn dlx jsr add @zerm/onexit

Import symbol

import * as onexit from "@zerm/onexit";

Add Package

vlt install jsr:@zerm/onexit

Import symbol

import * as onexit from "@zerm/onexit";

Add Package

npx jsr add @zerm/onexit

Import symbol

import * as onexit from "@zerm/onexit";

Add Package

bunx jsr add @zerm/onexit

Import symbol

import * as onexit from "@zerm/onexit";