Using Sub-Flow Env.Variable to set context failes

Hi,
I have a sub-flow that has an environment Variable, lets call it "FILENAME".
This variable will be set whenever the new sub-flow is used.
Inside the sub-flow, there is a function node with the following code:

filn = env.get("FILENAME");
// filn has a value like "test.txt"
ctx = flow.get(filn);
if (ctx == undefined){
   // The context does not exist, we set it
   flow.set(filn, 1)
   msg.payload = 1;
} else {
   msg.payload = 0;
}

Additionally I have a configuration where cache for context file-storage is disabled.
When I now deploy this configuration it failes with the following error:

"Error: File Store cache disabled - only asynchronous access supported"

If I do the same outside a Sub-Flow it works without any issue.

Can you help me to understand the reason or an option to get this functionality implemented?

Thanks a lot :slight_smile:

If you have disabled the cache for the file-store, then the store can only be accessed asynchronously.

filn = env.get("FILENAME");
// filn has a value like "test.txt"
flow.get(filn, function(err, ctx) {
  if (ctx == undefined){
     // The context does not exist, we set it
     flow.set(filn, 1, function(err) {
       msg.payload = 1;
       node.send(msg);
     });
  } else {
     msg.payload = 0;
     node.send(msg);
  }
});

Thank you Nick :slight_smile:
You helped me a lot. I don't know why I didn't notice of this section. :thinking:

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