Open inancgumus opened 2 years ago
This is also important to avoid data races from sharing goja.Runtime
. See https://github.com/grafana/xk6-browser/issues/254#issuecomment-1060380139 and https://github.com/grafana/xk6-browser/pull/263#pullrequestreview-905621976. The quickest relief would be to remove it from ElementHandle.eval()
.
quickest relief would be to remove it from ElementHandle.eval()
What's on your mind doing so? :)
Well, we currently pass goja.Value
s to this function, and to ExecutionContext.eval()
, and do the conversion inside it:
Instead, this should happen much higher up in the stack, as close as possible or inside the methods we already expose to JS, via this JS->Go translation layer. This way we should(?) ensure a single goroutine has access to the goja.Runtime
, and then when used internally we can worry about our own data races.
+1 That is exactly what I had in my mind: Goja should not enter into the extension logic realm.
This can also mitigate some of the known bugs caused by the concurrent Sobek usage throughout the extension 🤞
Runtime
is most needed because of Sobek conversions. If we can provide a translation layer between Sobek and the extension code, we can greatly simplify it. For example:This kind of cluttering happens because of internally exposing Sobek, whereas we could do:
See https://github.com/grafana/xk6-browser/pull/268#discussion_r822566026.