RegExp error with Kibana and RGraph


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Jan Dirk on 24th February 2016
I try to use RGraph in Kibana.
However, I now get an error (in Firefox) on the line

RegExp.$1 = '';


11:55:43.460 Error: setting a property that has only a getter
RG.number_format@localhost:5601/bundles/kibana.bundle.js?v=8467:164241:457
RG.getScale2@localhost:5601/bundles/kibana.bundle.js?v=8467:164037:66
RGraph.Scatter/this.Draw@localhost:5601/bundles/kibana.bundle.js?v=8467:166665:140
@localhost:5601/bundles/kibana.bundle.js?v=8467:163877:20
$RootScopeProvider/this.$get</Scope.prototype.$digest@localhost:5601/bundles/commons.bundle.js?v=8467:43433:24
$RootScopeProvider/this.$get</Scope.prototype.$apply@localhost:5601/bundles/commons.bundle.js?v=8467:43704:14
done@localhost:5601/bundles/commons.bundle.js?v=8467:38153:37
completeRequest@localhost:5601/bundles/commons.bundle.js?v=8467:38351:8
requestLoaded@localhost:5601/bundles/commons.bundle.js?v=8467:38292:1
1 commons.bundle.js:40084:19
consoleLog/<() commons.bundle.js:40084
$ExceptionHandlerProvider/this.$get</<() commons.bundle.js:36853
$RootScopeProvider/this.$get</Scope.prototype.$digest() commons.bundle.js:43451
$RootScopeProvider/this.$get</Scope.prototype.$apply() commons.bundle.js:43704
done() commons.bundle.js:38153
completeRequest() commons.bundle.js:38351
requestLoaded() commons.bundle.js:38292

I did also notice that Kibana (or one of the libraries used in Kibana) actually wraps the RGraph libraries and puts a 'use strict' before it.
This had the consequence, that I got several errors about non-declared variables.
I think that this 'strict' mode also might influence the error above.

Q1: What is the reason to try to clear this static variable Regexp.$1 ? It look like a 'hack' to clear the state of the RegExp class.
Q2: Can this error be fixed?
Q3: Can RGraph be made 'use strict' capable?
Posted by Richard on 24th February 2016
Hi,

Sorry I don't know what Kibana is nor am I familiar with it.

> Q1: What is the reason to try to clear this static variable Regexp.$1 ? It look like
> a 'hack' to clear the state of the RegExp class.

IIRC it's the standard way of retrieving matches of the preceding regular expression. There's more on regular expressions here:

developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

Be aware - it's a large subject!

> Q2: Can this error be fixed?

I have no idea. RGraph will most likely not run in strict mode.

Q3: Can RGraph be made 'use strict' capable?

Not without a significant amount of work I'd imagine. You could try taking out the 'use strict'; and seeing if it has any effect. (there might be multiple instances though).




Richard
Posted by Jan Dirk on 24th February 2016
Richard, thanks for the reply.

RegExp.$1 is indeed a 'getter' to retrieve the first group of a regular expression, which is parsed before.
However, in RGraph, this is tried to be set to an empty string. This looks a bit strange to me, but more problematic, Firefox does throw an error on it. Thus my question is merely, why is this done in the first place? Currently I've removed these assignments, but I do not know the consequence yet.
Posted by Richard on 24th February 2016
Hi,

ISTR that performing a regex which has matches then performing a second RegEx which has no matches still doesn't (or didn't) clear the first Regular expressions matches). So if you test for a match after the second regex then you may get false positives because of the first regex results still being there.

Could be wrong though - it is some time since I wrote bits of RGraph!

If you can comment it out and everything (the scale with pre/post units for example) still works - then leave it.





Richard

Add a reply

 




« Back to message list
RGraph on social media