Odd problem with function node in v1.1.3. Bug?

The node thinks there is an error in the function code. As it happens, there is an error as you can see from the raw data in the debug output.

But I don't know how the node could know that since it has no access to the incoming example msg. As far as the editor is concerned, msg.payload[package] certainly could be an array. There does not appear to be a syntax error in the code.

And, sure enough, correcting the "error" still leaves the node thinking there is a problem but the code runs perfectly well.

Of course, so the runtime error was certainly correct because I didn't spot the extra level in the data (npm stats output). However, the node should not be marked as in error as far as I can tell.

Here is the function in full:

const out = {}

Object.keys(msg.payload).forEach( package => {
    out[package] = {}
    let first = false
    msg.payload[package].downloads.forEach( entry => {
        // Loose any zeros until the first download
        if ( first === false ) {
            if ( entry.downloads === 0 ) return
            else first = true
        out[package][entry.day] = {
            'date': entry.day,
            'downloads': entry.downloads,

msg.payload = out

return msg;

I've not touched the Setup or Close parts or any other part of the function node.

Multiple ctrl-f5's to clear the caches didn't make a difference.

I can confirm that I don't get that error in v1.2 beta.

I also tried removing the flow, deploying then copy/paste a working version of the flow from my 1.2 beta instance. This successfully deploys with no error. However, if I then open the function node and add a space to the end of the first line, the error re-appears.

I replied in the previous thread, but it appears to have all been deleted, so has been lost.

In my reply I linked to another discussion that explains what you are seeing:

As part of another fix (discussed here with an explanation), some code was added to ensure ace errors would always be displayed (as they could sometimes be reported against line numbers outside of your actual code).

Sorry Nick, my fault for trying to tidy up something that clearly wasn't related to the new beta.

OK, so this is a known problem. It does appear to be fixed in 1.2 beta.

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