Skip to main content
onActivate is an optional (ctx) => Promise<void> hook that runs server-side after an activation is first persisted, and again whenever the activation data is updated. Use it to seed caches and sanity-check configuration early.

Basic hook

When it runs

  1. Once after activation is first persisted
  2. Again after the user updates their activation data (e.g., re-enters the API key)
Same ctx, same enforcement as schedules and tools.

Error handling

v1 errors are non-fatal. A throw is logged and shown to the user as a warning — the activation stays connected. This hook is for cache seeding and eager validation, not a connect gate: it cannot reject a connection. Do not repurpose it as a credential validator that must fail the connect.

Cache invalidation with fingerprints

When cache depends on activation data, store a fingerprint. On read, treat a mismatch as a cache miss:
Fingerprint every activation field that changes the cached values, not only the ones that select which data to fetch (units, currency, and locale leave a cache key untouched while making every number wrong). Make new fingerprint fields .optional(): a required field throws StorageValidationError on every pre-existing row, which for a clientReadable key reaches the widget.

Testing

Use invokeActivate():
invokeActivate() throws if onActivate is not declared, and lets a handler’s throw propagate — it is a bare invoker. The non-fatal handling is applied by whatever calls the hook (the host, or the harness’s activation surface), so a test of that behavior should catch the rejection itself.

Next steps