Help! Weird combine/concurrency bug


I successfully reduced the code that causes the crash and posted about it here.

Original Post

A unit test of mine is crashing due to some combination of Combine and swift concurrency, but the problem is that it's somewhat intermittent. I've been trying to reduce the code that reproduces the crash but the crash becomes more intermittent the more I reduce it, which caused me to decide to pause reducing and simply post some things here to see if anyone can provide some insight.

Here's the error message:

and here's the end of the stack trace:

In the unit test that crashes, in various places I wrap the objectDidChange as an AsyncPublisher and I await the next output before proceeding with the test. The test function is marked as both async and throws. I'll keep trying to reduce but I wanted to post this first.


Although not too familiar with combine, I'll hazard a guess.

You call objectDidChange.send() twice in a row and the error states that you didn't request demand.
So I am guessing you request data once somewhere but by calling it twice you are exceeding the available content. Either remove the second line or increase the demand before calling it.

1 Like