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
Mojo::UserAgent: Can't call method "_write" on an undefined value #1472
Comments
We need code to replicate the problem. |
I think it is not easy to make reproducable test script. Can you imagine why this callback called after object destruction? If you mean code which causes problem, this is it (simplified): for (1..$threads) {
check_next_url();
}
Mojo::IOLoop->start();
sub check_next_url {
my $period = int(rand($cfg->{max_check_period} - $cfg->{min_check_period} + 1 ) + $cfg->{min_check_period});
# is it time to check this URL?
my $time_left = $period - ( clock_gettime(CLOCK_MONOTONIC) - $urls[0]{time} );
if ($time_left > 0) {
Mojo::IOLoop->timer($time_left => \&check_next_url);
return;
}
my $url = shift @urls;
my $ua = Mojo::UserAgent->new();
$ua->max_redirects(0);
$ua->request_timeout(URL_CHECK_TIMEOUT);
my $proxy = $proxy[rand @proxy];
$ua->proxy->http($proxy)->https($proxy);
get_with_retry($ua, $url->{url}, sub {
my ($tx) = @_;
my $error = $tx->error;
# ...
$url->{time} = clock_gettime(CLOCK_MONOTONIC);
push @urls, $url;
undef $ua;
check_next_url();
});
}
sub get_with_retry {
my ($ua, $url, $cb, $cur_retry) = @_;
$ua->get($url, sub {
my ($ua, $tx) = @_;
my $error = $tx->error;
if (!$error || $error->{code} || ++$cur_retry > GET_RETRY_COUNT) {
return $cb->($tx);
}
get_with_retry($ua, $url, $cb, $cur_retry);
});
} |
Doesn't the $ua go out of scope in the code above? I think you should use one of our support channels for this instead: https://mojolicious.org/perldoc/Mojolicious/Guides/Contributing#SUPPORT |
We are loosing last reference to $ua at the end of callback: |
@olegwtf I've had this problem before. I patched it in our fork of Mojo. However. I forget what exactly it was. If you allow me to shoot in the dark though, can you edit your copy of Mojo::Util's
|
I got some stacktrace with Carp::Always:
Will try with EV backend. |
@EvanCarroll You mean to replace |
I have no errors with EV backend. |
Yes, i don't see any connection to whatever @EvanCarroll proposed there. But the example code above is also not enough to investigate. Unless there is new information i don't see this issue going anywhere. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This now also occured with EV (after I changed proxy type to HTTP).
|
I bet this would have already been fixed if there was test code we could actually run. |
I'll try to make it this time |
Just added this debug info to
Now in the trace I can see that
Is there some incorrect |
The best test case I can provide is this:
It starts to fail after 1-10 minutes of running. This proxy requires whitelist your IP. @kraih if u can provide your IP I can add it to whitelist. Here or to |
Finally I found out, that I can replicate this problem even without proxy enabled:
|
I still cannot replicate the problem with any of the test cases provided so far. |
Maybe try triggering it in a GitHub action? |
I've managed to trigger in an action and locally in docker container log edit This was/is a red herring. 1024 bits isn't enough on buster leading to an error. |
@olegwtf's test worked for me. |
This issue has been automatically marked as stale because it has not had recent activity. It may be closed if no further activity occurs. This is not a judgment on the merits of the issue, but an indication that more information may be needed to determine the appropriate course of action, if any. Thank you for your contributions. |
Still no way to replicate this. Afraid if there's no new information i'll have to call this a WONTFIX. |
Should be resolved. |
I am using Mojo::UserAgent in non-blocking way. Nothing special: about 100 parallel get requests with unstable socks proxy. Each request uses own Mojo::UserAgent object. In the log I can see such rare warnings:
Code on this line is:
Looks like internal Mojo::UserAgent issue. I don't think that some mistake in my code may produce this.
The text was updated successfully, but these errors were encountered: