I just updated my Synchronet binaries to the latest, and updated my JS scripts to the latest from CVS, and now when I try to read or list messages with my message reader (written in JS), I see the following error:
I've looked at smbdefs.js and it looks like it's only declared in there once, so I'm a little confused on why it's reporting that error.
I tried editing my copy of smbdefs.js and replaced the 'const' with 'var' where SMB_SUCCESS is declared, and that fixed the above error, but then it reported the same redeclaration error with the next one, SMB_DUPE_MSG. I've replaced all 'const' with 'var' in smbdefs.js and am not getting any of those redeclaration errors now. I'm not sure if that's the right fix though.
redeclaration of const SMB_SUCCESS
That tells you that you're load()ing smbdefs.js when it's already been loaded by something else. So, you've been unnecessarily re-evaluating/executing that script all this time.
The right fix is to use require() instead of load() for .js files that define constants (generally, load/*defs.js). require() is smart and will only load() the specified script if/when necessary. You use it like this:
Where the second argument is something that is defined in the load-file that you need in your script (a constant, variable or function). Then if that something is already defined, the load-file won't be executed since it's not necessary ('something' is already defined).
|Nodes:||4 (0 / 4)|