LAYER 02 · Learn the composition grammar

Effects and fibers: make disposal finish

Synchronous registration needs undo; asynchronous work needs quiescence—both are required

16 min3 source anchorsupstream@47f9438
register → disposer · start → stop → join
The question this chapter resolves

Why does AbortController.abort() not mean a plugin has finished unloading?

Build intuition

Closing a shop is more than flipping the sign. Stop new orders, let the kitchen settle, inventory equipment, return keys, and confirm nobody remains inside.

MECHANISM

Mechanism

Effects track synchronously reversible side effects such as services, listeners, and timers; context disposal unwinds their disposers by ownership.

Fibers own continuous or asynchronous work: request stop, then await done. Dependent worlds can unwind safely only after full quiescence.

Step 1 of 5

Register effect

Each registration returns an owned disposer.

INVARIANTS

What extensions must preserve

  • Requesting stop and confirming quiescence are distinct phases
  • Dispose must be idempotent
  • Consumers must stop before provider services are removed
FAILURE MODES

The tempting wrong turns

  • ×Fire-and-forget background promises
  • ×Clearing an interval without awaiting the active tick
  • ×Throwing in one disposer and preventing later cleanup
VERIFY IN SOURCE

Do not trust the conclusion—verify it

These anchors are pinned to official deepseek-harness@47f9438; account for later breaking changes when reading current upstream.

KNOWLEDGE CHECK

Pause for ten seconds before revealing

Why does HMR expose lifecycle bugs so quickly?

Why the next chapter follows

With reliable lifecycles, services and events can become stable cooperation protocols.

Learn DeepSeek Harness

An independent learning project. Explanations derive from source; upstream remains authoritative.