Skip to content

Commit 044fc3c

Browse files
committed
feat(api-graphql): add WebSocket health monitoring with persistent storage
- Add getConnectionHealth() and getPersistentConnectionHealth() methods - Add isConnected(), reconnect(), and disconnect() controls - Implement cross-platform persistent storage (AsyncStorage/localStorage) - Track keep-alive messages with 65-second health threshold - Fixes #9749, #4459, #5403, #7057
1 parent 669c55a commit 044fc3c

15 files changed

+1917
-15
lines changed
Lines changed: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
# MyTakeaway Critical Amplify Issues Analysis
2+
3+
## Summary
4+
5+
Analysis of critical AWS Amplify JavaScript issues that affect MyTakeaway (React Native food ordering application) after reviewing 400+ open issues and existing PR fixes.
6+
7+
**Last Updated**: 2025-09-27
8+
**Status**: **8 CRITICAL UNFIXED** and **8 HIGH-PRIORITY** issues identified that could significantly impact MyTakeaway.
9+
10+
---
11+
12+
## Issues Already Fixed by Your PRs
13+
14+
**#14534** - Random User Logouts - Fixed in PR #14568 (auth token clearing issue)
15+
- Users randomly logged out due to aggressive token clearing on any error
16+
- PR fixes by only clearing tokens for definitive auth failures, not network errors
17+
18+
**#12954** - DataStore Sync Processor Retry Error - Fixed in PR #14569 (WebSocket auth reconnection)
19+
- WebSocket subscriptions failed after ~24 hours when tokens expired
20+
- PR adds auth error detection to trigger WebSocket reconnection with fresh tokens
21+
22+
**#14514** - Expo SQLite Adapter Falling Back to AsyncStorage - Fixed in PR #14565 (ExpoSQLiteAdapter export and modernization)
23+
- ExpoSQLiteAdapter not exported and using deprecated APIs
24+
- PR exports adapter and modernizes to use expo-sqlite 13.0+ async API
25+
26+
**#13412** - DataStore Version Cross-Contamination - Fixed in PR #14570 (DataStore save version conflict)
27+
- Different model types with same ID incorrectly shared _version values
28+
- PR adds model type filter to prevent version cross-contamination
29+
30+
---
31+
32+
## COMPREHENSIVE ANALYSIS RESULTS
33+
34+
**Total Issues Analyzed**: 400+ open issues in AWS Amplify JavaScript repository
35+
**Analysis Method**: Comprehensive search using multiple filters and criteria
36+
**Focus**: React Native food ordering applications (MyTakeaway tech stack)
37+
38+
---
39+
40+
## 🔴 CRITICAL UNFIXED ISSUES (8 Remaining)
41+
42+
### **Issue #14406 - Token Refresh Fails After Expiry**
43+
- **Priority**: 🔴 **HIGHEST - CRITICAL**
44+
- **Problem**: `fetchAuthSession({ forceRefresh: true })` fails to initiate REFRESH_TOKEN_AUTH flow after idToken/accessToken expire, even with valid refreshToken
45+
- **Root Cause**: AWS team confirmed reproduction specifically with **custom CookieStorage** implementations
46+
- **Status**: AWS team has fix in progress (@pranavosu: "we're working on a fix")
47+
- **MyTakeaway Impact**:
48+
- Users lose session during long order flows
49+
- Delivery tracking sessions fail
50+
- Forces re-login interrupting order process
51+
- Critical for food ordering app user experience
52+
- **Evidence**: Multiple production reports, AWS team reproduced bug
53+
- **Not Fixed**: Your auth PRs addressed different issues (random logouts, WebSocket auth)
54+
55+
### **Issue #14458 - observeQuery Subscribe React Re-render**
56+
- **Priority**: 🟡 **MEDIUM-HIGH**
57+
- **Problem**: `client.models.observeQuery({ filter }).subscribe(({ items }) => setComments([...items]))` - subscription receives data but React doesn't re-render
58+
- **Root Cause**: AWS team (@bobbor) confirmed bug when using `setComments(items)` directly
59+
- **Status**: Under active investigation, AWS provided workarounds:
60+
- Use `setComments(() => [...items])` instead
61+
- Use `useReducer` instead of `useState`
62+
- **MyTakeaway Impact**:
63+
- Real-time order status updates may not display in UI
64+
- Order progress tracking not updating visually
65+
- Customer confusion about order status
66+
- **Evidence**: AWS team reproduced and confirmed as bug
67+
- **Not Fixed**: None of existing PRs address React re-rendering issues
68+
69+
### **Issue #14247 - DataStore Missing Lambda Updates**
70+
- **Priority**: 🟡 **MEDIUM**
71+
- **Problem**: DataStore doesn't detect updates made by Lambda functions, even when Lambda uses proper AppSync GraphQL mutations
72+
- **Root Cause**: DataStore subscriptions don't trigger for Lambda-initiated updates
73+
- **Status**: User found workaround (using AppSync mutations in Lambda) but core issue remains
74+
- **MyTakeaway Impact**:
75+
- Backend order processing updates don't sync automatically
76+
- Kitchen/restaurant updates not reflected in real-time
77+
- Delivery status changes from external systems missed
78+
- **Evidence**: User provided detailed Lambda implementation showing issue
79+
- **Not Fixed**: Existing PRs don't address Lambda-triggered updates
80+
81+
### **Issue #14522 - fetchAuthSession Returns Null Tokens Without Error**
82+
- **Priority**: 🔴 **CRITICAL**
83+
- **Problem**: `fetchAuthSession()` returns `{ tokens: null }` without throwing errors during `NotAuthorizedException` from token refresh
84+
- **MyTakeaway Impact**: Silent authentication failures causing unexpected logouts
85+
- **Status**: OPEN with 16 comments, partially addressed by PR #14568 but core issue remains
86+
- **Evidence**: Multiple production reports of silent auth failures
87+
- **Note**: PR #14568 fixes some cases but null token return without error still occurs
88+
89+
### **Issue #13957 - SQLite Transaction Performance Causing CPU Spikes**
90+
- **Priority**: 🔴 **CRITICAL - PERFORMANCE**
91+
- **Problem**: DataStore SQLite transactions extremely slow, causing system CPU spikes and app freezes
92+
- **MyTakeaway Impact**: Order processing delays, UI freezes during peak usage
93+
- **Status**: No fix yet, affects all SQLite-based DataStore implementations
94+
- **Evidence**: Performance profiling shows transaction bottlenecks
95+
96+
### **Issue #14440 - DataStore Not Using SQLite, Falls Back to Memory**
97+
- **Priority**: 🔴 **CRITICAL - DATA LOSS**
98+
- **Problem**: DataStore silently falls back to in-memory storage instead of SQLite
99+
- **MyTakeaway Impact**: Order data lost on app restart, no offline persistence
100+
- **Status**: OPEN with minimal AWS response
101+
- **Evidence**: Users report lost order data after app restarts
102+
- **Note**: Partially addressed by PR #14565 for Expo projects, but core issue remains for React Native
103+
104+
### **Issue #14096 - Expo SQLite Incompatibility**
105+
- **Priority**: 🟡 **MEDIUM** (Downgraded - Fixed by PR #14565)
106+
- **Problem**: DataStore incompatible with modern Expo SQLite, forces legacy dependencies
107+
- **MyTakeaway Impact**: Cannot upgrade Expo SDK, security and performance issues
108+
- **Status**: FIXED by PR #14565 for Expo SDK 50+
109+
- **Evidence**: Expo SDK upgrade blocked by DataStore dependencies
110+
- **Resolution**: PR #14565 modernizes ExpoSQLiteAdapter for expo-sqlite 13.0+
111+
112+
---
113+
114+
## 🟡 HIGH-PRIORITY ISSUES (8 Found)
115+
116+
### **Issue #13769 - DataStore Doesn't Sync with @auth Owner Rules**
117+
- **Priority**: 🟡 **HIGH**
118+
- **Problem**: DataStore fails to sync when using `@auth` owner authorization rules
119+
- **MyTakeaway Impact**: User-specific order data not syncing properly
120+
- **Status**: Affects multi-user order management
121+
- **Evidence**: Authorization-related sync failures
122+
123+
### **Issue #13609 - HasOne Relationship Returns Null on Create/Update**
124+
- **Priority**: 🟡 **HIGH**
125+
- **Problem**: HasOne relationship fields return null during create/update mutations
126+
- **MyTakeaway Impact**: Order-to-user relationships broken, data consistency issues
127+
- **Status**: Relationship integrity problems
128+
- **Evidence**: Null relationship data in mutations
129+
130+
### **Issue #14043 - Cannot Filter _deleted Items with syncExpression**
131+
- **Priority**: 🟡 **HIGH**
132+
- **Problem**: DataStore syncExpression cannot filter out deleted items
133+
- **MyTakeaway Impact**: Deleted orders still appear in app, confusing UX
134+
- **Status**: Filtering limitation affects data presentation
135+
- **Evidence**: Deleted items visible to users
136+
137+
### **Issue #13896 - Invalid Predicate Error Termination**
138+
- **Priority**: 🟡 **HIGH**
139+
- **Problem**: DataStore terminates with invalid predicate errors during complex queries
140+
- **MyTakeaway Impact**: Order filtering and search functionality broken
141+
- **Status**: Query reliability issues
142+
- **Evidence**: App crashes during order search operations
143+
144+
### **Issue #14467 - Query Operators Don't Work with Composite Sort Keys in GSI**
145+
- **Priority**: 🟡 **HIGH**
146+
- **Problem**: ge, le, between operators fail with composite sort keys in Global Secondary Indexes
147+
- **MyTakeaway Impact**: Order date/time range queries broken
148+
- **Status**: Query functionality limitation
149+
- **Evidence**: Time-based order filtering not working
150+
151+
### **Issue #14421 - uploadData Progress Calculation Wrong (Android)**
152+
- **Priority**: 🟡 **HIGH - ANDROID ONLY**
153+
- **Problem**: Upload progress incorrectly calculated on Android, causes UI issues
154+
- **MyTakeaway Impact**: Order photo uploads show wrong progress, user confusion
155+
- **Status**: Platform-specific bug
156+
- **Evidence**: Android users report incorrect upload indicators
157+
158+
### **Issue #13845 - TypeScript Compilation Errors with DataStore Types**
159+
- **Priority**: 🟡 **HIGH - DEVELOPMENT**
160+
- **Problem**: DataStore TypeScript types cause compilation errors in Angular/strict mode
161+
- **MyTakeaway Impact**: Development workflow issues, type safety problems
162+
- **Status**: TypeScript compatibility issues
163+
- **Evidence**: Build failures with strict TypeScript configs
164+
165+
### **Issue #13644 - Angular Build Errors with TypeScript 5+**
166+
- **Priority**: 🟡 **HIGH - DEVELOPMENT**
167+
- **Problem**: Amplify types incompatible with TypeScript 5+ in Angular projects
168+
- **MyTakeaway Impact**: Cannot upgrade TypeScript, security and performance lag
169+
- **Status**: Dependency constraint issues
170+
- **Evidence**: Build system incompatibilities
171+
172+
---
173+
174+
## Technical Details
175+
176+
### Issue #14406 Details
177+
```javascript
178+
// Fails after token expiry despite valid refreshToken
179+
const session = await fetchAuthSession({ forceRefresh: true });
180+
// Returns undefined instead of refreshing tokens
181+
```
182+
183+
**Problem Flow**:
184+
1. idToken + accessToken expire (5 min in testing)
185+
2. refreshToken still valid (15+ min)
186+
3. `fetchAuthSession({ forceRefresh: true })` called
187+
4. No Cognito REFRESH_TOKEN_AUTH request made
188+
5. Returns undefined silently
189+
190+
### Issue #14458 Details
191+
```javascript
192+
// Subscription works but React doesn't re-render
193+
subscription = await client.models.Comment.observeQuery({
194+
filter: { pollId: { eq: poll.id } }
195+
}).subscribe(({ items }) => {
196+
setComments([...items]) // Doesn't trigger re-render
197+
})
198+
```
199+
200+
**Workarounds**:
201+
- `setComments(() => [...items])`
202+
- Use `useReducer` instead of `useState`
203+
204+
### Issue #14247 Details
205+
```javascript
206+
// Lambda updates DynamoDB but DataStore doesn't sync
207+
const updateRoomMutation = `
208+
mutation UPDATE_ROOM($input: UpdateRoomInput!) {
209+
updateRoom(input: $input) { id lastMessageId }
210+
}
211+
`;
212+
// Updates work but DataStore.observe() doesn't trigger
213+
```
214+
215+
---
216+
217+
## PRIORITY RECOMMENDATIONS (UPDATED)
218+
219+
### **IMMEDIATE ACTION REQUIRED** (Next 1-2 weeks)
220+
221+
**1. Target Issue #14406 (Token Refresh) - HIGHEST PRIORITY**
222+
- **Why**: Session continuity essential for order completion
223+
- **Impact**: Users logged out during long delivery tracking sessions
224+
- **Action**: AWS team has fix in progress, can contribute/accelerate
225+
- **Status**: Well-documented reproduction case, affects custom CookieStorage
226+
227+
**2. Target Issue #14440 (Data Loss Risk) - CRITICAL**
228+
- **Why**: Silent data loss is unacceptable for food ordering
229+
- **Impact**: Order data disappearing = lost revenue + customer complaints
230+
- **Action**: Investigate DataStore SQLite adapter initialization
231+
- **Note**: Partially fixed for Expo in PR #14565, needs React Native fix
232+
233+
**3. Target Issue #13957 (SQLite Performance) - PERFORMANCE CRITICAL**
234+
- **Why**: UI freezes = poor user experience during peak hours
235+
- **Impact**: App unusable during high order volume
236+
- **Action**: Profile and optimize SQLite transaction batching
237+
- **Evidence**: CPU spike reports from production users
238+
239+
### **MEDIUM-TERM PLANNING** (Next 1-2 months)
240+
241+
**4. Issue #14458 (React Re-render Bug)**
242+
- Real-time order status updates not displaying
243+
- AWS team confirmed bug, workarounds available
244+
245+
**5. Issue #14522 (Silent Auth Failures)**
246+
- Related to #14534, affects session reliability
247+
- Needs coordinated fix with token refresh issues
248+
249+
**6. Issue #14096 (Expo SQLite Compatibility)**
250+
- Blocks Expo SDK upgrades
251+
- Architectural change needed for DataStore
252+
253+
### **LONG-TERM ARCHITECTURAL** (Next 3-6 months)
254+
255+
**7. DataStore Modernization Initiative**
256+
- Address SQLite adapter issues (#14440, #14096, #13957)
257+
- Improve transaction performance and reliability
258+
- Ensure compatibility with modern React Native/Expo
259+
260+
**8. Authentication Reliability Project**
261+
- Comprehensive fix for token refresh issues (#14406, #14522, #14534)
262+
- Improve session management for long-running apps
263+
- Better error handling and user experience
264+
265+
---
266+
267+
## Other Issues Identified (Lower Priority)
268+
269+
### Issues with Some Activity but Not Critical for MyTakeaway:
270+
- **#14467** - Query operators ge, le and between don't work with composite sort keys in GSI
271+
- **#14459** - rtn-web-browser does not open browser on Chromebook
272+
- **#14421** - Expo/React-Native uploadData function calculating onProgress incorrectly (Android-only)
273+
- **#14440** - Amplify datastore is not using sqlite
274+
- **#14561** - Switching Cognito User Pools in React Native fails after app refresh
275+
- **#13845** - TypeScript compilation errors with DataStore types (Angular compatibility)
276+
- **#13644** - Angular build errors with TypeScript 5+ (resolved with skipLibCheck workaround)
277+
- **#13769** - DataStore does not sync if using owner @auth
278+
- **#13609** - HasOne relationship field returns null on create/update mutations
279+
- **#14096** - DataStore compatibility with Expo SQLite instead of react-native-sqlite-storage
280+
- **#14043** - Cannot filter _deleted items with DataStore syncExpression
281+
- **#13957** - SQLite Transaction is very slow causing system CPU spike
282+
- **#13896** - Invalid predicate error termination
283+
284+
### Your Successfully Fixed Issues:
285+
- **#14568** - PR fixing #14534 (Random user logouts due to token clearing)
286+
- **#14569** - PR fixing #12954 (WebSocket subscriptions failing after token expiration)
287+
- **#14565** - PR fixing #14514 (ExpoSQLiteAdapter export and modernization)
288+
- **#14570** - PR fixing #13412 (DataStore version cross-contamination)
289+
290+
---
291+
292+
## Files for Reference
293+
294+
- **Critical Unfixed Issue URLs**:
295+
- #14406: https://github.com/aws-amplify/amplify-js/issues/14406
296+
- #14458: https://github.com/aws-amplify/amplify-js/issues/14458
297+
- #14247: https://github.com/aws-amplify/amplify-js/issues/14247
298+
299+
- **Your Successful PRs**:
300+
- PR #14568: https://github.com/aws-amplify/amplify-js/pull/14568
301+
- PR #14569: https://github.com/aws-amplify/amplify-js/pull/14569
302+
- PR #14565: https://github.com/aws-amplify/amplify-js/pull/14565
303+
- PR #14570: https://github.com/aws-amplify/amplify-js/pull/14570
304+
305+
- **Key Files to Investigate for #14406**:
306+
- Token refresh logic in auth provider
307+
- CookieStorage token retrieval
308+
- fetchAuthSession implementation
309+
- Cognito token provider refresh flow
310+
311+
---
312+
313+
**Generated**: 2025-09-27
314+
**Context**: MyTakeaway React Native food ordering application using DataStore, Auth, and real-time subscriptions

.claude/settings.local.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"WebFetch(domain:github.com)",
5+
"Bash(gh api:*)",
6+
"Bash(gh issue view:*)",
7+
"Bash(npm test:*)",
8+
"WebSearch",
9+
"Read(//Users/anivar/Dev/work/mytakeaway2.0/**)",
10+
"Bash(npm run build:*)",
11+
"Bash(git add:*)",
12+
"Bash(git push:*)",
13+
"Bash(gh issue list:*)",
14+
"Bash(gh pr list:*)",
15+
"Bash(gh pr view:*)",
16+
"Bash(npm run build:esm:api-graphql:*)",
17+
"Bash(npx jest:*)",
18+
"Bash(npx eslint:*)",
19+
"Bash(gh pr edit:*)",
20+
"Bash(git rebase:*)"
21+
],
22+
"deny": [],
23+
"ask": []
24+
}
25+
}

0 commit comments

Comments
 (0)