Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-3045

SSE loses last message when sink is closed after message delivery

XMLWordPrintable

    • Hide

      Run the test to reproduce RESTEASY-3033, it can be found at https://github.com/resteasy/resteasy/pull/2938 .

      If you take in the fix for the deadlock, and comment out the check which fails due to RESTEASY-4044:

      // Assert.assertTrue("Wrong message order in run " + run + " " + results, results.get(i).endsWith("-" + i)); 

      You will see that the test times out because as it did not receive the last-msg for one of its requests.
      Commenting out the closure of the {{sink.close()}}fixes the issue and shows that the problem is related to the server side closure of the sink.
      This problem happens in around 2-3% of the requests, the tests executes 100 requests.

      Show
      Run the test to reproduce RESTEASY-3033 , it can be found at https://github.com/resteasy/resteasy/pull/2938 . If you take in the fix for the deadlock , and comment out the check which fails due to RESTEASY-4044: // Assert.assertTrue( "Wrong message order in run " + run + " " + results, results.get(i).endsWith( "-" + i)); You will see that the test times out because as it did not receive the last-msg for one of its requests. Commenting out the closure of the {{sink.close()}}fixes the issue and shows that the problem is related to the server side closure of the sink. This problem happens in around 2-3% of the requests, the tests executes 100 requests.

      When the server side sends an SSE event. wait for its delivery and then directly closes the sink.  It is still possible that the message gets lost on the client side:
      In code it looks like this:

      sink.send(sse.newEvent("last-msg")).thenAccept(v -> sink.close());

      It is as if the CompletionStage of sink.send completes just a little too early, and it is still possible to close the sink while the last message is on its way.

      With the test to reproduce RESTEASY-3033 we found 2 other issues, this is one of them. the other is RESTEASY-3044.

              jperkins-rhn James Perkins
              steven.aerts Steven Aerts (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: