
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@karinjs/long-timeout
Advanced tools
Modern ESM implementation of long-timeout with full TypeScript support.
使用现代化语法(TypeScript + ESM + Node.js 18+)完全重写的 long-timeout,支持超过 2^31-1 毫秒(约 24.8 天)的超时和定时器。
npm install @karinjs/long-timeout
当你需要设置超过 2,147,483,647 毫秒(约 24.8 天)的定时器时,Node.js 的原生 setTimeout 和 setInterval 会立即触发。long-timeout 通过内部分段的方式解决了这个限制。
import { setTimeout, setInterval, clearTimeout, clearInterval } from '@karinjs/long-timeout'
// 设置一个超过 24.8 天的超时(这里示例 30 天)
const timeout = setTimeout(() => {
console.log('30 天后执行!')
}, 30 * 24 * 60 * 60 * 1000) // 30 天
// 设置一个长间隔定时器(每 7 天执行一次)
const interval = setInterval(() => {
console.log('每 7 天执行一次')
}, 7 * 24 * 60 * 60 * 1000) // 7 天
// 清除定时器
clearTimeout(timeout)
clearInterval(interval)
import { Timeout, Interval } from '@karinjs/long-timeout'
// 创建一个 Timeout 实例
const timeout = new Timeout(() => {
console.log('Timeout 触发!')
}, 3000000000) // 约 34.7 天
// 允许进程在此定时器激活时退出
timeout.unref()
// 阻止进程退出
timeout.ref()
// 取消定时器
timeout.close()
// 创建一个 Interval 实例
const interval = new Interval(() => {
console.log('Interval 触发!')
}, 2592000000) // 30 天
interval.unref()
interval.close()
import longTimeout from '@karinjs/long-timeout'
const timeout = longTimeout.setTimeout(() => {
console.log('使用默认导出')
}, 3000000000)
longTimeout.clearTimeout(timeout)
setTimeout(listener: () => void, after: number): Timeout设置一个长超时定时器。
listener: 超时后执行的回调函数after: 延迟时间(毫秒)Timeout 实例setInterval(listener: () => void, after: number): Interval设置一个长间隔定时器。
listener: 每次间隔执行的回调函数after: 间隔时间(毫秒)Interval 实例clearTimeout(timer: Timeout | Interval | null | undefined): void清除一个定时器。
timer: 要清除的定时器实例clearInterval(timer: Timeout | Interval | null | undefined): void清除一个定时器(clearTimeout 的别名)。
Timeout长超时定时器类。
构造函数:
constructor(listener: () => void, after: number)
方法:
unref(): void - 允许 Node.js 进程在此定时器是唯一活跃定时器时退出ref(): void - 阻止 Node.js 进程退出close(): void - 取消超时定时器Interval长间隔定时器类。
构造函数:
constructor(listener: () => void, after: number)
方法:
unref(): void - 允许 Node.js 进程在此定时器是唯一活跃定时器时退出ref(): void - 阻止 Node.js 进程退出close(): void - 取消间隔定时器Node.js 的原生定时器使用 32 位整数存储延迟时间,最大值为 2^31-1(2,147,483,647 毫秒,约 24.8 天)。超过这个值会导致定时器立即触发。
long-timeout 通过以下方式解决这个问题:
TIMEOUT_MAX(2^31-1)TIMEOUT_MAX 的定时器TIMEOUT_MAX,然后设置最终的定时器unref() 可以避免定时器阻止进程退出MIT
FAQs
Modern long-timeout, ts + esm + node v18+.
We found that @karinjs/long-timeout demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.