Skip to content

Fix PDF viewer ENOENT crash after app resumes from background#126

Open
gumclaw wants to merge 2 commits intomainfrom
fix/pdf-viewer-background-resume-enoent
Open

Fix PDF viewer ENOENT crash after app resumes from background#126
gumclaw wants to merge 2 commits intomainfrom
fix/pdf-viewer-background-resume-enoent

Conversation

@gumclaw
Copy link
Copy Markdown

@gumclaw gumclaw commented Mar 29, 2026

Summary

  • Sentry Issue: GUMROAD-MOBILE-11
  • On Android, when the app goes to background and the OS cleans up cached temp files (especially under memory pressure), react-native-pdf tries to copy a non-existent .pdf.tmp file on resume, causing an unhandled ENOENT error that bypasses the onError prop
  • Fix by listening for AppState changes and forcing a fresh Pdf component remount (via key increment) when Android returns to foreground, so the library starts a clean download instead of referencing stale temp files

Test plan

  • Added tests for AppState listener registration, Android remount on resume, iOS no-op on resume, and cleanup on unmount
  • Manual test: open a PDF on Android, background the app for a few minutes, return to foreground — PDF should reload cleanly
  • Verify iOS behavior is unaffected

🤖 Generated with Claude Code

On Android, when the app goes to background and the OS cleans up temp
files (especially under memory pressure), react-native-pdf tries to
copy a non-existent .pdf.tmp file on resume, causing an unhandled
ENOENT error. Fix by listening for AppState changes and forcing a
fresh Pdf remount when Android returns to foreground.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants