Cant update getWorkflowStaticData('global') with Gmail Trigger

Describe the problem/error/question

I created a workflow where in a gmail trigger will update the getWorkflowStaticData(‘global’). The problem is that gmail trigger does not update it. I already tested the workflow by turning on the active button.

What is the error message (if any)?

There is no error message

Please share your workflow

Share the output returned by the last node

I was expecting the counter to be incremented by 1

Information on your n8n setup

  • n8n version: 1.79.3
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Linux

I observe similar behaviour and was able to reproduce the case on n8n cloud v1.81.4.

I tested the active workflow properly triggering Google Sheet and Gmail triggers - similar behaviour.

The Code node javascript code:

const data = $getWorkflowStaticData('global');

const dataIn = JSON.stringify(data);
let branch;

if (data.counter) {
  data.counter++;
  branch = "increment";
} else {
  data.counter = 1
  branch = "INIT";
}

const dataOut = JSON.stringify(data);

// debugging details to observe in executions tab
return [{ 
  json: { 
    executionId: $execution.id,
    experimentCode: $input.first().json.Subject ?? $input.first().json.UUID4,
    dataIn, 
    branch, 
    dataOut, 
    counter: data.counter,
  } 
}];

I noticed however that any, even slightest change (e.g. delete or add a non-critical whitespace in the code, manipulating other nodes) to the workflow that is being saved afterwards “forces” the code to actually properly change the content of the workflow static data.

I assume the static data is widely used by others and if it was a bug, someone would have already reported it. What is it that @Manage_Bnb and I are very likely overlooking here?

Could someone from n8n team and/or community please look into this and explain?

Doc for reference: getWorkflowStaticData | n8n Docs

Playground template:

I was able to reproduce this error in n8n 1.80.5 docker installed. Whenever Gmail Trigger node is run for the first time, it actually updates the getWorkflowStaticData(‘global’). However, the next time it run it will not update getWorkflowStaticData(‘global’).

I tried to find some workaround in here and I found one. However I dont really like this workaround.

The workaround is using a Subworkflow node.

So this is how it looks like

So what it does it execute another workflow. The subworkflow looks like this

This is just a band-aid solution and I hope n8n devs will resolve this.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.