root: Job<unknown>

The "main" job of the program or bundle, which all other jobs should be a child of. This provides a single point of configuration and cleanup, as one can e.g.:

  • Use root.asyncCatch() to define the default async error handling policy
  • Use root.end() to clean up all resources for the entire program
  • Use root.start() to create top-level, standalone, or "daemon"/service tasks, or to create tasks whose lifetime is managed by an external framework.

By default, there is only ever one root job, run once, in a given process or page. But for testing you can use newRoot to end the existing root and start a new one.

Remarks

Uneventful does not include any code to end the root job itself, as the decision of when and whether to do that varies heavily by context (e.g. server vs. browser, app vs. plugin, etc.), and often doesn't need to happen at all. (Because exiting the process or leaving the web page is often sufficient.)

More commonly, you will only end the root job when running tests (to get a clean environment for the next test), or when your entire bundle is itself an unloadable plugin (e.g. in Obsidian).

Note, too, that when the root job ends, root is reset to null so that any subsequent attempt to use the root job will throw an exception. (Unless of course a new root job has been created with newRoot.)