Commit d8a8c09
Fix race condition in bearer-rejection retry link that triggered "link chain completed without emitting a value"
When the server sends X-Bearer-Token-Rejected, BatchHttpLink calls
observer.next(result) and then observer.complete() synchronously in the
same Promise .then(). The next handler detected the rejection and kicked
off an async token refresh without forwarding the value — but the
synchronous complete: () => observer.complete() fired before the retry
could emit, triggering Apollo Client 4's validateDidEmitValue guard.
Fix: call activeSubscription.unsubscribe() synchronously inside the next
handler the moment bearer rejection is detected. This marks the rxjs
Subscriber as isStopped before BatchHttpLink's .complete() runs, so
that call becomes a no-op. The retry then proceeds normally and emits
a value through a fresh subscription.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 97194c1 commit d8a8c09
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
| 126 | + | |
128 | 127 | | |
129 | 128 | | |
130 | 129 | | |
131 | 130 | | |
132 | 131 | | |
133 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
134 | 141 | | |
135 | 142 | | |
136 | 143 | | |
| |||
0 commit comments