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 🙏

© 2024 – Pkg Stats / Ryan Hefner

watch-task-protocol

v0.3.0

Published

The main goal of the watch-task-protocol is making it possible to coordinate multiple watch processes. These are processes that don't exit after a build, but instead continue to rebuild as soon as file-changes are detected. The problem with such processes

Downloads

1

Readme

watch-task-protocol

The main goal of the watch-task-protocol is making it possible to coordinate multiple watch processes. These are processes that don't exit after a build, but instead continue to rebuild as soon as file-changes are detected. The problem with such processes is that they cannot coordinate themselves with each other. So if both lib and app detect filechanges at the same time, both processes will immediately start re-building. This is a problem, because re-building app only makes sense after lib is built successfully.

So what I came up with to solve this problem is a protocol for such processes to communicate with the task coordinator or task runner. With this protocol, a watch process can notify the runner about changes, and the runner can notify the process when it's time to re-start the task. Additionally, the task can tell the runner if it was successful or not.

The cool thing is that processes not implementing the protocol are still fully compatible with the protocol. Not implementing the protocol means that a process exits after the task is complete and that it's restarted to run the task again. Only if a process wants to stay alive and still tell the task runner that its job is completed, it needs make use of the watch-task-protocol.

The protocol is very simple:

  1. When the process starts, immediately runs the task
  2. After the task is successful, write WATCH_TASK_PROTOCOL:SUCCEEDED to STDOUT, or if the task failed write WATCH_TASK_PROTOCOL:FAILED
  3. Do not restart the task until you receive WATCH_TASK_PROTOCOL:START on STDIN, then immediately restart it and continue to 2.
  4. A process can exit at any point, this also means the task is completed and the process shall be restarted the next time the task needs to run.
  5. Sometimes a watch process knows best, when it's time to re-run the task because it knows its task the best after all. In this case, it can at any point write WATCH_TASK_PROTOCOL:DETECTED_CHANGES to STDOUT. This tells the task runner that it wants to re-run. But remember, it's the task runners job to actually trigger the re-run. So don't restart the task until you receive the WATCH_TASK_PROTOCOL:START message.