Problem: - Multiple rapid calls to sendTranscript() created race conditions - Old requests continued using local abortController variable - Responses from superseded requests could still be processed - Session stop didn't reliably prevent pending responses Solution: - Changed abort checks from `abortController.signal.aborted` to `abortControllerRef.current !== abortController` - Ensures request checks if it's still the active one, not just aborted - Added checks at 4 critical points: before API call, after API call, before retry, and after retry Changes: - VoiceContext.tsx:268 - Check before initial API call - VoiceContext.tsx:308 - Check after API response - VoiceContext.tsx:344 - Check before retry - VoiceContext.tsx:359 - Check after retry response Testing: - Added Jest test configuration - Added test suite with 5 race condition scenarios - Added manual testing documentation - Verified with TypeScript linting (no new errors) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
810 B
JavaScript
28 lines
810 B
JavaScript
module.exports = {
|
|
preset: 'jest-expo',
|
|
testEnvironment: 'jsdom',
|
|
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
|
transformIgnorePatterns: [
|
|
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)',
|
|
],
|
|
moduleNameMapper: {
|
|
'^@/(.*)$': '<rootDir>/$1',
|
|
},
|
|
collectCoverageFrom: [
|
|
'contexts/**/*.{ts,tsx}',
|
|
'services/**/*.{ts,tsx}',
|
|
'hooks/**/*.{ts,tsx}',
|
|
'!**/*.d.ts',
|
|
'!**/node_modules/**',
|
|
'!**/__tests__/**',
|
|
],
|
|
testMatch: [
|
|
'**/__tests__/**/*.test.{ts,tsx}',
|
|
'**/?(*.)+(spec|test).{ts,tsx}',
|
|
],
|
|
testPathIgnorePatterns: [
|
|
'/node_modules/',
|
|
'/.ralphy-worktrees/',
|
|
],
|
|
};
|