Problem with pcre_compile2
Closed this issue · 6 comments
Hi all, I'm facing a problem with pcre_compile2
. The message displayed is:
Thrown:
SyntaxError: pcre_compile2("\.([^.(?!)+)") failed: missing terminating ] for character class at "" in xxxxx.js:y
in line y I have:
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
the versions used are:
- nginx 1.25.3
- njs 0.8.2
What could be happening?
Thanks in advance
As a fellow NJS user, I think this might actually be less of an NJS issue and more of a regex validity issue. That pcre2_compile error pops up whenever the regex has some issue in it. It's just a weird way that NJS reports that.
You have a few different regexes listed in this:
The one in the error is this:
\.([^.(?!)+)
That appears to be missing a closing ] in it so if you are using that regex somewhere, you might need to add a closing ]
The second regex that you quoted in your code is this:
\.([^.[]+)
For that one, I think you might need to escape the [ within the character class.
I could be misreading your intended regex patterns - particularly since you have two different regexes. But it might be worth trying those two tweaks.
Thank you for your fast answer.
Let me add some context. I'm following this guide: http://nginx.org/en/docs/njs/node_modules.html because I need to use ioredis
library from njs code. After build the single file and include to my base code, this error appears and the code belongs to ioredis library.
If you need more info like the webpack configuration file or any other thing.
Hi @jcerro,
Let me save your time on porting ioredis
to njs. It will not work because it depends on node.js IO API (sockets and networking in general). What can be ported are pure JS libraries. For example a cryptographic library or a compression library that does just compression, not IO.
Talking about redis support. We plan to add a native API for njs to work with redis.
@xeioex thank you so much, it took me lot of time to obtain a green build. I'm going to close the issue.
Talking about redis support. We plan to add a native API for njs to work with redis.
Do you have a timeline 😄?