Array functions not working in while loop

Describe the issue/error/question

I have a while loop that I use to pull some values from multiple 2 value arrays. It has been working fine for months. I went to edit it today to add something to my message and now I get error, even with the original code. The error is saying it cannot access a null value. However, if I run the same code outside the loop it works fine. I tried .pop, but I was using [1] in place of where .pop() was. Both give me similar errors.

With .pop(): ERROR: Cannot read property ‘pop’ of null [Line 15 | Item Index: 0]
With [1]: ERROR: Cannot read property ‘1’ of null [Line 15 | Item Index: 0]

What is the error message (if any)?

Please share the workflow

while(counter < len ){

let regMsg = msg.exec(data[counter].message).pop();

let regUser = user.exec(data[counter].message).pop();

let regSrcip = srcip.exec(data[counter].message).pop();

message = message + "User: " + regUser + " had a successful Admin Login into " + data[counter].hostname + " on " + data[counter].display_received_at + " from " + regSrcip + "\n" + "\n" ;

(Select the nodes and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow respectively)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm,, desktop app]:

So I tried with the production webhook using srcip.exec(data[counter].message)[1] (on all of them) and it works fine.

Hey @pccurnow, I am sorry to hear you’re having trouble. I am not sure I have all context required to understand the problem though.

Are you your JavaScript code in a Function node? If so, could you share the full code of your Function node as well as the data you’re passing on to that node?