npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lionad/bin-timeout-wrapper

v0.1.0

Published

Universal binary timeout wrapper - add timeout protection to any binary via npx

Readme

@lionad/bin-timeout-wrapper

One-command timeout protection for any binary. Transparent, reversible, zero config.

npx @lionad/bin-timeout-wrapper -- /path/to/unstable-binary

important: Mac only, relies on perl alarm for timeouts.

Why

主要用来修复我的 Mac 的一个异常问题。

VSCode 曾有个困扰我许久的问题,他会调用 rg(ripgrep)来做全局搜索,但似乎偶尔会死循环,吃满我的 CPU。

但通过设置 followSymlink 设置没有效果,而 rg 死循环出现得很随机,所以我不想花大量时间做插件的二分排查。

鉴于没有操作系统级别的 debug 技能,所以我才使用这种“兽医手术”的下策:在 rg 上套一层超时保护,超时后自动 kill。

Usage

Wrap(加超时)

npx @lionad/bin-timeout-wrapper --timeout 5 -- /path/to/binary

This creates a shell wrapper at the original path and moves the real binary to {binary}_backup. The wrapper uses perl alarm to enforce the timeout — no extra dependencies on macOS.

Output:

Wrapped: /path/to/binary
  Backup: /path/to/binary_backup
  Timeout: 5s (override with BIN_TIMEOUT env var)

Restore(还原)

npx @lionad/bin-timeout-wrapper --restore -- /path/to/binary

Removes the wrapper and restores the original binary from backup.

Status(查看状态)

npx @lionad/bin-timeout-wrapper --status -- /path/to/binary

Checks whether a binary is currently wrapped, showing:

  • Wrap status (wrapped / not wrapped)
  • Timeout setting
  • Backup file location
  • Creation time (when wrapped)

Enable Logging(启用执行日志)

npx @lionad/bin-timeout-wrapper --timeout 5 --enable-log -- /path/to/binary

When enabled, the wrapper logs all executions to .bin-timeout-wrapper.log in the same directory as the backup file:

[1775034123456] executed
[1775034123457] timeout

Timestamps are millisecond Unix timestamps. The log file is created on first execution and appended to on subsequent runs.

Configuration

| Variable | Default | Description | | --- | --- | --- | | BIN_TIMEOUT | 5 | Timeout in seconds. Set at runtime to override the wrap-time default. |

# Use 10s timeout for a specific invocation
BIN_TIMEOUT=10 rg "search pattern"

Real-World Example

# working too long...
rg -j12 -uuu --max-depth 999 "." ~/Library

# so wrap it with a timeout 5s for testing
npx @lionad/bin-timeout-wrapper --timeout 1 -- $(which rg)

# now it died after 5s instead of "working forever"
rg -j12 -uuu --max-depth 999 "." ~/Library

# restore it back to normal if you want
npx @lionad/bin-timeout-wrapper --restore -- $(which rg)

How It Works

  1. Backup: Moves the original binary to {name}_backup
  2. Replace: Creates a shell script at the original path that wraps execution with perl alarm
  3. Proxy: The wrapper forwards all arguments and I/O to the real binary
  4. Timeout: If execution exceeds the limit, perl sends SIGKILL (exit code 137)

The wrapper script itself is ~10 lines of POSIX sh + perl — both standard on macOS.

Options

--timeout N      Timeout in seconds (default: 5)
--enable-log     Enable execution logging to .bin-timeout-wrapper.log
--restore        Restore the original binary
--status         Check wrap status
--help           Show usage information

License

MIT