preaction / Mercury

A message broker for WebSockets
Other
10 stars 8 forks source link

Fails with Mojolicious 7.83 #44

Open eserte opened 6 years ago

eserte commented 6 years ago

The pubsub.t test started to fail on my smokers:

Mojo::Reactor::EV: I/O watcher failed: Can't call method "_write_content" on an undefined value at /home/cpansand/.cpan/build/2018060612/Mojolicious-7.83-K_ZDdd/blib/lib/Mojo/IOLoop/Stream/WebSocketServer.pm line 10.

        #   Failed test 'sub received message'
        #   at t/pubsub.t line 38.

        #   Failed test 'exact match for message'
        #   at t/pubsub.t line 38.
        #          got: ''
        #     expected: 'Hello'
        # Looks like you failed 2 tests of 6.

    #   Failed test 'publish on child topic'
    #   at t/pubsub.t line 44.
    # Looks like you failed 1 test of 3.

#   Failed test 'topic hierarchy'
#   at t/pubsub.t line 84.
Can't call method "_write_content" on an undefined value at /home/cpansand/.cpan/build/2018060612/Mojolicious-7.83-K_ZDdd/blib/lib/Mojo/IOLoop/Stream/WebSocketClient.pm line 10.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 2.
t/pubsub.t ............. 
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/2 subtests 

Statistical analysis suggests that the failure started with Mojolicious 7.83:

****************************************************************
Regression 'mod:Mojolicious'
****************************************************************
Name                   Theta          StdErr     T-stat
[0='const']           1.0000          0.0000    13873760165956166.00
[1='eq_7.19']        -0.0000          0.0000      -0.97
[2='eq_7.32']        -0.0000          0.0000      -0.77
[3='eq_7.33']        -0.0000          0.0000      -1.16
[4='eq_7.46']        -0.0000          0.0000      -1.16
[5='eq_7.51']        -0.0000          0.0000      -1.54
[6='eq_7.57']        -0.0000          0.0000      -1.54
[7='eq_7.58']        -0.0000          0.0000      -0.97
[8='eq_7.62']        -0.0000          0.0000      -2.92
[9='eq_7.64']        -0.0000          0.0000      -2.18
[10='eq_7.65']       -0.0000          0.0000      -1.95
[11='eq_7.67']       -0.0000          0.0000      -0.97
[12='eq_7.68']       -0.0000          0.0000      -4.31
[13='eq_7.70']       -0.0000          0.0000      -3.71
[14='eq_7.71']       -0.0000          0.0000      -3.87
[15='eq_7.75']       -0.0000          0.0000      -1.47
[16='eq_7.81']        0.0000          0.0000       0.00
[17='eq_7.82']       -0.0000          0.0000      -1.54
[18='eq_7.83']       -1.0000          0.0000    -13433210518006022.00

R^2= 1.000, N= 171, K= 19
****************************************************************
preaction commented 6 years ago

It looks like that's being caused by the new Mojolicious streams code: A weakened reference is becoming undef, and then a method is being called on it. https://github.com/kraih/mojo/blob/master/lib/Mojo/IOLoop/Stream/WebSocketServer.pm#L10

It doesn't seem to me that my test is doing anything too outlandish, except maybe making multiple Test::Mojo objects and having them all running at the same time. It seemed to work, but that doesn't make it a feature.

Checking for !$self in the Mojo::IOLoop::Stream::WebSocketServer code before calling the method solves the problem and makes the tests pass, but I'm not going to risk being told off for reporting something that isn't a bug to Mojolicious again, so I guess I'll just wait and see if someone else comes across this...