Getting this error when try to use forEach on an array passed to a function : TypeError: users.forEach is not a function

Your code is passing whatever is returned by global.get('users') to your function.

The most simple explanation is that isn't returning an array.

How are you setting the value of users in global context to begin with? That isn't shown in this code.

You could add a node.warn(users) after the call to global.get so you can see exactly what you've got.