Steps
How we tested, and what is real
On 29 October 2026 we ran about 35 real executions on a self-hosted n8n 2.43.7 (SQLite, Node 24). Each workflow used
$getWorkflowStaticData()in a Code node, and after every run we read the saved static data straight from the n8n database. We tested production webhook calls, editor (manual) runs, the CLI, a server restart, failing runs, parallel calls, and the data types that survive. Every result below is what we saw.Quick answer: only production runs save static data
Static data is saved only when an active (published) workflow runs from its production trigger: a production webhook URL, a Schedule Trigger, a polling trigger. When we clicked run in the editor, the Code node read the stored value and returned the incremented count, but the database never changed: the next manual run returned the same number again. The test webhook URL runs in manual mode too (per the n8n docs). So if your counter or "last ID" never moves while you test, it is working as designed. Activate the workflow and call the production URL.
Mutate the object, do not replace it
const s = $getWorkflowStaticData('global'); s.count = (s.count || 0) + 1;saved every time (1, 2, 3, still 4 after restarting n8n). Butlet s = $getWorkflowStaticData('global'); s = { count: 1 };never saved anything: three runs returned 1, 1, 1 and the database stayed empty. n8n saves the object it handed you, so change its properties. Nested changes work:s.obj.n++ands.list.push(x)both persisted.A failed execution throws your writes away
When the Code node wrote a new value and then threw an error, the webhook got HTTP 500
Error in workflowand nothing was saved, three times in a row. Static data is only written at the end of a successful execution. If a later node fails, your "last processed ID" stays at the old value and the next run processes the same items again. Either let the run succeed (On Error: Continue on the risky node) or accept the replay and remove duplicates.Parallel runs lose updates
We sent 3 webhook calls at the same moment to a workflow that read the counter, waited 1.5 s, and wrote count + 1. All three returned 1, and after a 4th call the stored count was 2, not 4. Each execution saves its own copy at the end, and the last one wins. Static data is not a lock or a safe counter. For counters or queues hit in parallel, use a database, Redis (
INCR) or a Data Table, or limit the workflow to one execution at a time.Dates, Maps and undefined do not survive
Static data is stored as JSON. A
Datecame back on the next run as a string (typeofreturnedstring), aMapcame back as an empty object{}with its data gone, and keys set toundefinedwere dropped. Store dates as ISO strings or timestamps, and use plain objects and arrays.Global or node scope
$getWorkflowStaticData('global')is shared by every node in the workflow.$getWorkflowStaticData('node')is stored per node under a key with the node name, for examplenode:Code, so two Code nodes do not see each other's node data. If you read from one node and write from another, use global.The "remember the last ID" pattern
This worked across runs in our tests (IDs 1, 6, 11, then 15 stored):
Run it on an active workflow, and remember that a failed run later in the workflow will not moveconst s = $getWorkflowStaticData('global'); const last = s.lastId || 0; const fresh = $input.all().filter(i => i.json.id > last); if (fresh.length) s.lastId = Math.max(...fresh.map(i => i.json.id)); return fresh;lastId.See or reset the stored value
Download the workflow as JSON: when static data exists it is in the
staticDatafield. Importing the same workflow again with the CLI kept the existing static data in our test. To reset it, run once with code that deletes the keys (delete s.lastId) from a production trigger, since manual runs do not save.
All test results
Real executions on n8n 2.43.7, with static data read from the database after each run.
| Test | Result |
|---|---|
| Production webhook, global count x3 | 1, 2, 3 saved; after restart next call returned 4 |
| Editor (manual) run x2 | Returned 3 twice; database stayed at 2 (not saved) |
CLI n8n execute --id | Saved (1, then 2) |
Reassign the variable (s = {...}) | Returned 1, 1, 1; nothing saved |
Nested s.obj.n++, s.list.push() | Saved: {"obj":{"n":3},"list":[1,2,3]} |
| Code node writes then throws | 500 Error in workflow x3; nothing saved |
| 3 parallel calls, read, wait 1.5 s, write | All returned 1; stored count 2 after a 4th call (lost updates) |
Store a Date | Next run got a string |
Store a Map | Next run got {} (data lost) |
| Key set to undefined | Dropped |
| Node scope | Stored under node:<node name> |
| lastId pattern, ids 1, 6, 11 | Only new items returned each run; lastId 15 stored |
| Re-import workflow with the CLI | Existing static data kept |
Checklist
- Testing in the editor or on the test webhook URL? Nothing is saved. Activate the workflow and use the production trigger.
- Change properties of the object; never reassign the variable.
- Did the execution fail? Its writes are discarded.
- Several runs at once? Expect lost updates; use a database, Redis or a Data Table.
- Store dates as strings and use plain objects, not Map or Set.
- Writing in one node and reading in another? Use global scope.
Good to know
- Skipping items you already processed without code: n8n Remove Duplicates across executions. Storing state in a table instead: n8n Data Table not working and n8n Redis node errors.
- Code node problems: n8n Code node errors. Workflows that never run on schedule: n8n Schedule Trigger not working.
- Every error text from our guides: n8n error message index.
What we did not test
n8n Cloud, queue mode with several workers, Postgres as the n8n database, renaming a node that holds node-scope data, and polling trigger nodes that use static data internally.
Start from a working agent
FAQ
Why is n8n static data not saving?
In our tests it was saved only by production executions of an active workflow. Editor runs and the test webhook URL read it but never save it. It is also lost when you reassign the variable or when the execution fails.
Does $getWorkflowStaticData work in manual executions?
It reads the stored value, but changes are not saved. Our manual runs returned the same count twice while the database did not change.
Is n8n static data kept after a restart?
Yes. Our counter continued from 3 to 4 after restarting n8n, because it is stored in the database with the workflow.
Can I use n8n static data as a counter for parallel executions?
Not safely. Three simultaneous runs all read the same value and the last save won, so updates were lost. Use Redis INCR, a database or a Data Table.
How do I reset n8n workflow static data?
Delete the keys in a Code node and run it from the production trigger, since manual runs do not save. You can see the current value in the staticData field of the downloaded workflow JSON.
Related guides
- n8n Execution Data node not saving? 23 tests, every silent drop
- n8n Loop Over Items not working? 15 tests of what really happens
- n8n Respond to Webhook not working: empty body, Invalid JSON, 28 runs
- n8n Sort node not sorting correctly: numbers, dates and nulls, 33 runs
- n8n Notion node not working: "API token is invalid.", data source and 404 fixes
New guides
- GitHub release notifications in Slack (any public repo, stable releases only)
- Send RSS feeds to Slack with a keyword filter (free, incoming webhook)
- Forward emails to a Slack channel (Gmail, Outlook, any IMAP), free with an incoming webhook
- n8n Google Sheets Trigger not working: not firing, activation errors and fixes