# Context from localfilesystem: flow.get synchronous error

**URL:** <https://discourse.nodered.org/t/context-from-localfilesystem-flow-get-synchronous-error/19079>\
**Category:** General\
**Created:** [12 December 2019 15:23 UTC](https://discourse.nodered.org/t/context-from-localfilesystem-flow-get-synchronous-error/19079 "2019-12-12T15:23:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbrito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gbrito/32/3915_2.png) [@gbrito](https://discourse.nodered.org/u/gbrito)\
**Post date:** [12 December 2019 15:23 UTC](https://discourse.nodered.org/t/context-from-localfilesystem-flow-get-synchronous-error/19079/1 "2019-12-12T15:23:45Z")

</div>

Hi everyone,

Using node-red v1.0.3 with nodejs v10.

I've started to use the context from localFileSystem, for persistence.  
I managed to use it and store items with global.set(...) and flow.set(...) inside function nodes.

The bug i've found is when i try to retrieve **synchronously** from the file contextStore. Using function node i have this:

```auto
//ASYNC - working
/*flow.get('count','file',function(err, myCount) {
    if(err){
        node.error(err, msg);
    }else{
        msg.payload=myCount;
        node.send(msg);
    }    
});*/

//SYNC - not working
var a = flow.get('count','file');
msg.payload=a;
return msg;

```

And i get the following error:  
**12/12/2019, 15:03:10[node: c5ed7f86.e463](https://localhost:1889/#)function : (error)**  
**"Error: Callback must be a function"**

I've tracked down the path into the following file from source: @node-red/runtime/lib/nodes/context/localfilesystem.js -\> line 248

where it seems that its always expecting a callback function even if its sync:

```auto
LocalFileSystem.prototype.get = function(scope, key, callback) {
...
    if(typeof callback !== "function"){
        throw new Error("Callback must be a function");
    }
...

```

Hope you guys can fix it shortly,

Cheers,  
G.B.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 December 2019 16:23 UTC](https://discourse.nodered.org/t/context-from-localfilesystem-flow-get-synchronous-error/19079/2 "2019-12-12T16:23:39Z")

</div>

If possible, please raise an issue on GitHub with the details so we can take a look.

> **[node-red/node-red](https://github.com/node-red/node-red)**
>
> Low-code programming for event-driven applications - node-red/node-red

Thanks

---

<div class="post-metadata">

**Author:** ![gbrito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gbrito/32/3915_2.png) [@gbrito](https://discourse.nodered.org/u/gbrito)\
**Post date:** [12 December 2019 16:56 UTC](https://discourse.nodered.org/t/context-from-localfilesystem-flow-get-synchronous-error/19079/3 "2019-12-12T16:56:56Z")

</div>

> If possible, please raise an issue on GitHub with the details so we can take a look.

Done it. In fact, after I posted here, i was wondering if posting it on Github was more convenient. x)  
Thanks

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [12 December 2019 17:31 UTC](https://discourse.nodered.org/t/context-from-localfilesystem-flow-get-synchronous-error/19079/4 "2019-12-12T17:31:56Z")

</div>

In general it's best to raise it here first, just in case it's something someone already recognises, or has a fix for already.
