Storage Events
A storage event runs a flow after a document is created, updated or removed. The flow receives the current document and a list of what changed. Rapid updates can arrive combined, and a flow that writes back must guard against write loops.
Four events cover a document's changes
| Event | Fires when |
|---|---|
on_created |
A new document is created in the storage. |
on_saved |
A new document is created, or an existing document is updated. |
on_updated |
An existing document is updated. |
on_removed |
An existing document is marked as removed. |
Events start in order, but nodes can overtake each other
Storage events run First In, First Out, but several nodes can execute at the same time. While Node A is processing Event 61, Node B might already be executing Event 62, because Node A is also processing Event 60 and Node B is not. Nodes differ in speed, so the FIFO order cannot be guaranteed.
Inside the flow you can manage order with lock or wait blocks, but this may slow other events executing in the same thread and block. Move intensive work out of the event flow and into a queue.
The flow receives the current document and what changed
On a create or an update you get the most recent document data and a list of the fields that changed. The document represents the current state at the moment of the event.
| Out-pin | Holds |
|---|---|
object | The current document. |
revisions | Every change: the key, its value and its previous_value. |
fields_modified | The names of the fields that changed. |
storage, user_guids | The storage that raised the event, and user guids. |
Events are fast, and may occasionally be combined. The examples below show what the event carries in each case.
A created document
{
"username": "Joe",
"_meta": {
"guid": "a23575f49d0af385314c1f02280163374297e018a692e5e4ab85eb307ebf6ebc",
"expiry": -1,
"entity": 1,
"removed": 0,
"created": 1706396400,
"updated": 1706396400,
"ums": 1706396400803,
"cms": 1706396400362,
"update_hash": "60e27209fa93063b5605e41605c2722ed428cae0"
}
}{
"object": {
"username": "Joe",
"_meta": {
"guid": "a23575f49d0af385314c1f02280163374297e018a692e5e4ab85eb307ebf6ebc",
"expiry": -1,
"entity": 1,
"removed": 0,
"created": 1706396400,
"updated": 1706396400,
"ums": 1706396400803,
"cms": 1706396400362,
"update_hash": "60e27209fa93063b5605e41605c2722ed428cae0"
}
},
"revisions": [
{
"key": "username",
"value": "Joe",
"previous_value": null
}
],
"fields_modified": [
"username"
]
}An updated document
{
"username": "Joe Do",
"firstname": "Joe",
"lastname": "Do",
"_meta": {
"guid": "a23575f49d0af385314c1f02280163374297e018a692e5e4ab85eb307ebf6ebc",
"expiry": -1,
"entity": 1,
"removed": 0,
"created": 1706396400,
"updated": 1706482800,
"ums": 1706482800417,
"cms": 1706396400362,
"update_hash": "8fc1d0b6a4e37225b1904c7de0f5a8c6431bb27e"
}
}{
"object": {
"username": "Joe Do",
"firstname": "Joe",
"lastname": "Do",
"_meta": {
"guid": "a23575f49d0af385314c1f02280163374297e018a692e5e4ab85eb307ebf6ebc",
"expiry": -1,
"entity": 1,
"removed": 0,
"created": 1706396400,
"updated": 1706482800,
"ums": 1706482800417,
"cms": 1706396400362,
"update_hash": "8fc1d0b6a4e37225b1904c7de0f5a8c6431bb27e"
}
},
"revisions": [
{
"key": "username",
"value": "Joe Do",
"previous_value": "Joe"
},
{
"key": "firstname",
"value": "Joe",
"previous_value": null
},
{
"key": "lastname",
"value": "Do",
"previous_value": null
}
],
"fields_modified": [
"username",
"firstname",
"lastname"
]
}Fast updates arrive as one combined event
When updates occur at high speed, the events may be consolidated. If a key was modified several times, it appears several times in the revisions array.
{
"username": "Joe",
"firstname": "Joe",
"_meta": {
"guid": "a23575f49d0af385314c1f02280163374297e018a692e5e4ab85eb307ebf6ebc",
"expiry": -1,
"entity": 1,
"removed": 0,
"created": 1706396400,
"updated": 1706482800,
"ums": 1706482800417,
"cms": 1706396400362,
"update_hash": "8fc1d0b6a4e37225b1904c7de0f5a8c6431bb27e"
}
}{
"username": "Joe",
"lastname": "Do",
"_meta": {
"guid": "a23575f49d0af385314c1f02280163374297e018a692e5e4ab85eb307ebf6ebc",
"expiry": -1,
"entity": 1,
"removed": 0,
"created": 1706396400,
"updated": 1706482800,
"ums": 1706482800419,
"cms": 1706396400362,
"update_hash": "b7440ac2915de6f038c1a55eb9376d024f8ce1a3"
}
}{
"object": {
"username": "Joe",
"firstname": "Joe",
"lastname": "Do",
"_meta": {
"guid": "a23575f49d0af385314c1f02280163374297e018a692e5e4ab85eb307ebf6ebc",
"expiry": -1,
"entity": 1,
"removed": 0,
"created": 1706396400,
"updated": 1706482800,
"ums": 1706482800419,
"cms": 1706396400362,
"update_hash": "b7440ac2915de6f038c1a55eb9376d024f8ce1a3"
}
},
"revisions": [
{
"key": "firstname",
"value": "Joe",
"previous_value": null
},
{
"key": "lastname",
"value": "Do",
"previous_value": null
}
],
"fields_modified": [
"firstname",
"lastname"
]
}A flow that writes can feed itself forever
A flow triggered by a storage event can write documents, and those writes raise storage events of their own. This composes across blueprints: if the on_saved flow for storage A updates a document in storage B, and the on_saved flow for storage B updates a document in storage A, the two flows feed each other forever.
Each blueprint is locally correct. The studio shows one blueprint at a time, so the cycle never appears on any canvas: it only exists in the composition. The same applies to a single flow that re-saves a document in its own storage.
Guard every store write inside an event flow
Skip the events it would raise
Pass skip_on_saved in the options of function_update_document_mutations or function_create_document_from_mutations. The write happens, no storage events fire for it, and the chain ends there. The right default for derived or mirrored data.
Cascade on purpose, with a termination condition
If downstream flows must react to the write, add a data condition that makes the second pass a no-op. For example, compare the value before writing and only write when it actually changes. Without such a condition, the cascade is an infinite loop by construction.
The platform cancels runaway chains
A loop starves within one generation instead of running forever. Two independent checks apply:
- By identity. Every storage event carries its chain's lineage: which storage and document raised each earlier hop. A flow may re-enter its own document once; that is what the termination-condition pattern relies on. The second time the same document on the same storage re-enters its own chain, the event is cancelled with
BLUEPRINT_LOOP. A two-storage cycle dies after about 5 hops, a self-loop after about 3. - By depth. Any chain deeper than 10 storage-event hops is cancelled the same way. This backstop covers loops the identity check cannot see, such as flows that create a new document each generation.
A cancelled event runs no flows, so it raises no further writes and the chain produces no next generation.
What the log tells you
| Log line | Meaning |
|---|---|
| Informational line naming a suspected cycle | Your flow re-entered a document it already wrote in this chain. It still ran, because one revisit is allowed, but a second re-entry will be cancelled. Treat it as an early warning: check whether the cascade is intentional and has a termination condition. |
BLUEPRINT_LOOP warning |
The platform cancelled a runaway chain. The line names the storages and documents in the cycle; that is where to find the blueprints to fix. |
Next steps
Storages The document model and the mutations these events report. Queue Where the heavy part of an event flow belongs.Frequently asked
Which storage events does RUAL support?
Four: on_created when a new document is created, on_updated when an existing document is updated, on_saved for either, and on_removed when a document is marked as removed. Each fires a flow through the storage_event block.
Do RUAL storage events run in order?
Not guaranteed. Events are processed first in, first out, but multiple nodes execute them simultaneously at different speeds, so strict FIFO order cannot be guaranteed. For a hard execution order, offload the intensive work to the queue.
What data does a RUAL storage event contain?
The most recent document data, a revisions array with the key, value and previous_value of each modified field, and a fields_modified list. When updates happen at high speed, events may be consolidated into one.
What does BLUEPRINT_LOOP mean in RUAL?
The platform cancelled a runaway storage-event chain: two storage event flows were writing to each other's storage, or a chain grew deeper than 10 storage-event hops. The log line names the storages and documents in the cycle. Fix the flows by passing skip_on_saved on the store write, or give a deliberate cascade a termination condition.
