@@ -40,7 +40,6 @@ public final class RealtimeChannelV2: Sendable {
40
40
41
41
let logger : ( any SupabaseLogger ) ?
42
42
let socket : RealtimeClientV2
43
- let maxRetryAttempt = 5
44
43
45
44
@MainActor var joinRef : String ? { mutableState. joinRef }
46
45
@@ -86,7 +85,7 @@ public final class RealtimeChannelV2: Sendable {
86
85
87
86
/// Subscribes to the channel.
88
87
public func subscribeWithError( ) async throws {
89
- logger? . debug ( " Starting subscription to channel ' \( topic) ' (attempt 1/ \( maxRetryAttempt ) ) " )
88
+ logger? . debug ( " Starting subscription to channel ' \( topic) ' (attempt 1/ \( socket . options . maxRetryAttempts ) ) " )
90
89
91
90
status = . subscribing
92
91
@@ -100,12 +99,12 @@ public final class RealtimeChannelV2: Sendable {
100
99
101
100
var attempts = 0
102
101
103
- while attempts < maxRetryAttempt {
102
+ while attempts < socket . options . maxRetryAttempts {
104
103
attempts += 1
105
104
106
105
do {
107
106
logger? . debug (
108
- " Attempting to subscribe to channel ' \( topic) ' (attempt \( attempts) / \( maxRetryAttempt ) ) "
107
+ " Attempting to subscribe to channel ' \( topic) ' (attempt \( attempts) / \( socket . options . maxRetryAttempts ) ) "
109
108
)
110
109
111
110
try await withTimeout ( interval: socket. options. timeoutInterval) { [ self ] in
@@ -117,10 +116,10 @@ public final class RealtimeChannelV2: Sendable {
117
116
118
117
} catch is TimeoutError {
119
118
logger? . debug (
120
- " Subscribe timed out for channel ' \( topic) ' (attempt \( attempts) / \( maxRetryAttempt ) ) "
119
+ " Subscribe timed out for channel ' \( topic) ' (attempt \( attempts) / \( socket . options . maxRetryAttempts ) ) "
121
120
)
122
121
123
- if attempts < maxRetryAttempt {
122
+ if attempts < socket . options . maxRetryAttempts {
124
123
// Add exponential backoff with jitter
125
124
let delay = calculateRetryDelay ( for: attempts)
126
125
logger? . debug (
@@ -136,7 +135,7 @@ public final class RealtimeChannelV2: Sendable {
136
135
}
137
136
} else {
138
137
logger? . error (
139
- " Failed to subscribe to channel ' \( topic) ' after \( maxRetryAttempt ) attempts due to timeout "
138
+ " Failed to subscribe to channel ' \( topic) ' after \( socket . options . maxRetryAttempts ) attempts due to timeout "
140
139
)
141
140
}
142
141
} catch is CancellationError {
0 commit comments