# Help! Weird combine/concurrency bug

**URL:** <https://forums.swift.org/t/help-weird-combine-concurrency-bug/56570>\
**Category:** Using Swift\
**Tags:** concurrency, crash, combine, publisher, asyncawait\
**Created:** [April 6, 2022, 12:39pm UTC](https://forums.swift.org/t/help-weird-combine-concurrency-bug/56570 "2022-04-06T12:39:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyabannister](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jeremyabannister/32/10143_2.png) [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Post date:** [April 6, 2022, 12:39pm UTC](https://forums.swift.org/t/help-weird-combine-concurrency-bug/56570/1 "2022-04-06T12:39:38Z")

</div>

## Update

I successfully reduced the code that causes the crash and posted about it [here](https://forums.swift.org/t/asyncpublisher-causes-crash-in-rather-simple-situation/56574).

## 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:

 ![Screen Shot 2022-04-06 at 2.24.27 PM](https://global.discourse-cdn.com/swift/original/3X/9/5/95710fcfa0e530d2ab63bcf8f1e4b9838587fb40.png)

and here's the end of the stack trace:

 ![Screen Shot 2022-04-06 at 2.31.11 PM](https://global.discourse-cdn.com/swift/original/3X/0/8/08f7ed080ca82a9639363dc2dafbd40ece69db8b.png)

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.

Thanks!

---

<div class="post-metadata">

**Author:** ![Terje](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Terje](https://forums.swift.org/u/Terje)\
**Post date:** [April 6, 2022, 5:02pm UTC](https://forums.swift.org/t/help-weird-combine-concurrency-bug/56570/2 "2022-04-06T17:02:56Z")

</div>

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.
