Skip to content
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

disable TracePoint properly #788

Merged
merged 1 commit into from
Dec 27, 2018
Merged

disable TracePoint properly #788

merged 1 commit into from
Dec 27, 2018

Conversation

ko1
Copy link
Contributor

@ko1 ko1 commented Dec 12, 2018

if super raise an exception, this very danger TracePoint is not disabled.
This is why https://bugs.ruby-lang.org/issues/15400

This change is introduced at: #751

Anyway, this approach is very danger (for example, tmp variable name is not exposed API), so that pls re-consider to use this technique.

if `super` raise an exception, this very danger TracePoint is not disabled.
This is why https://bugs.ruby-lang.org/issues/15400

This change is introduced at: bblimke#751

Anyway, this approach is very danger (for example, `tmp` variable name is not exposed API), so that pls re-consider to use this technique.
@@ -285,7 +285,7 @@ def rbuf_fill
end

super

ensure

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Ruby 2.6, the TracePoint#enable takes target: keyword argument.
We can use TracePoint#enable with the target: to enable the TracePoint for the specific method.
What do you think?

        trace.enable(target: WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetBufferedIO.instance_method(:rbuf_fill)) do
          super
        end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you == me?

It is better. But I think this TracePoint approach is danger, even with this limitation.

@bblimke
Copy link
Owner

bblimke commented Dec 12, 2018

Any thoughts of how to avoid using trace point to achieve the same behaviour?

@ko1
Copy link
Contributor Author

ko1 commented Dec 12, 2018

Not sure because I don't know about net/protocol.rb, but modifying @rbuf? monkey patching is better than it because you need to check the behavior change (maybe you specify the version more explicitly).

@lamont-granquist
Copy link

ping? it might be better to remove tracepoint, but merging this would unblock our 2.6 testing.

@bblimke bblimke merged commit ddf3191 into bblimke:master Dec 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants