01 · Before and afterThe pattern
// before: create, store, done
const sub = await graph.createSubscription(token);
await kv.set(key, sub);
// after: the owner may have gone during the call
const sub = await graph.createSubscription(token);
await kv.set(key, sub);
if (!(await connectionStillExists(accountId))) {
await graph.deleteSubscription(token, sub.id);
await kv.delete(key);
}02 · Run it on your appThe check
If a user disconnects an integration in the second your app is still setting it up, is anything left running on the third-party side?
If the honest answer is no or not sure, this is worth a look before it reaches production.