Currently, Pipedream components are stateless between workflow executions. Each run creates a fresh component instance with default prop values, making it impossible to maintain state across workflow runs without using external storage mechanisms like $.flow.setState().
// This doesn't work - props reset to default values between runs
export default defineComponent({
props: {
purchases: {
type: "integer",
default: 26
}
},
async run({ steps, $ }) {
// This always starts at 26, never persists
const storedPurchases = this.purchases;
const newPurchases = await getNewPurchases();
if (newPurchases > storedPurchases) {
this.purchases = newPurchases; // Doesn't persist between runs
}
}
});
Proposed Solution
Enable persistent component state that maintains prop values between workflow executions, similar to React component state management.
export default defineComponent({
props: {
purchases: {
type: "integer",
default: 26,
persistent: true // new flag
}
},
async run({ steps, $ }) {
const storedPurchases = this.purchases; // Gets persisted value
const newPurchases = await getNewPurchases();
if (newPurchases > storedPurchases) {
this.purchases = newPurchases; // Persists between runs
// Continue with expensive operation
} else {
return { skip: true, reason: "No changes detected" };
}
}
});
There is no need to make a request to flow state and it lowers compute costs for simple counter props that don’t need to be stored.