# Combine: inconsistent share() behavior

**URL:** <https://forums.swift.org/t/combine-inconsistent-share-behavior/39029>\
**Category:** Using Swift\
**Tags:** combine\
**Created:** [August 4, 2020, 4:30am UTC](https://forums.swift.org/t/combine-inconsistent-share-behavior/39029 "2020-08-04T04:30:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZfHxFr](https://avatars.discourse-cdn.com/v4/letter/z/b19c9b/32.png) [@ZfHxFr](https://forums.swift.org/u/ZfHxFr)\
**Post date:** [August 4, 2020, 4:30am UTC](https://forums.swift.org/t/combine-inconsistent-share-behavior/39029/1 "2020-08-04T04:30:19Z")

</div>

During my learning of retry and share operators, I composed the following codes:

```
enum MyError: Error {
    case testError
}    

[1,2].publisher
.tryMap {
    if $0 > 1 { throw MyError.testError }
    return $0
}
.retry(2)
.sink(receiveCompletion: { print($0) },
      receiveValue: { print($0) })

```

Prints fulfills expectation,

```
1
1
1
failure(__lldb_expr_485.MyError.testError)

```

However, when I add a share operator, the result is confusing to me.

```
[1,2].publisher
.share()
.tryMap {
    if $0 > 1 { throw MyError.testError }
    return $0
}
.retry(2)
.sink(receiveCompletion: { print($0) },
      receiveValue: { print($0) })

// 1
// 1
// finished

```

It seems like the retry is executed once, and then mysteriously succeeds.
