-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix this.memory(key, falsy)
not working in JavaScriptAgent
#1551
Conversation
This spots a bug in `getMemory()`.
@@ -114,12 +114,9 @@ def execute_js(js_function, incoming_events = []) | |||
context["getOptions"] = lambda { |a, x| interpolated.to_json } | |||
context["doLog"] = lambda { |a, x| log x } | |||
context["doError"] = lambda { |a, x| error x } | |||
context["getMemory"] = lambda do |a, x, y| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if how much more efficient it would be, but would it make sense to keep getMemory
with one argument to not always pass the whole memory through the javascript bridge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree, but there's currently no one-argument use for the function and this is meant to be a minimal fix. We can make further improvements later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As handling of variable length arguments is awkward [*] in V8 (and JavaScript itself), I'd rather have a separate functions for getting the whole memory and an individual key value.
[*] Ruby's lambda
has a stricter argument length check compared to proc
, but V8::Context seems to adjust arguments on the caller side, which gives me a confused feeling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, that's not really the scope of this PR.
I was wondering how that even works, so V8 has to check the arity of the lambda and fill the missing arguments with nil?
Looks good to me 👍 |
LGTM too. Thanks @knu! |
cf. #1543 (comment)