question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while restoring state in react-native

See original GitHub issue

I am using this library to persist redux store to allow for offline operations in my mobile application developed using react-native. Kudos on creating this awesome library. I was able to setup an offline layer in my application fairly easily. Lately, I keep getting this error after I refresh the app a few times

[
tid:com.facebook.react.JavaScript] 'Error restoring data for key:', 'contacts', { [Error: Failed to read storage file.Error Domain=NSCocoaErrorDomain Code=256 "(null)" UserInfo={NSFilePath=/Users/abc/Library/Developer/CoreSimulator/Devices/1BC0FBB2-F8CD-4972-9C33-15D7FB969B38/data/Containers/Data/Application/5DF58B17-541B-4B67-8AE3-D015EB5B757F/Documents/RCTAsyncLocalStorage_V1/90eb5e54838e5b2f33b011f232b016dd, NSUnderlyingError=0x7f8c2f2c33c0 {Error Domain=NSPOSIXErrorDomain Code=24 "Too many open files"}}]
  line: 61916,
  column: 18,
  sourceURL: 'http://localhost:8081/index.ios.bundle?platform=ios&dev=true',
  key: 'reduxPersist:contacts' }

Does this error have something to do with this library? Could this be a bug in the AsyncStorage adapter where files are not closed after persisting?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aguynamedbencommented, Dec 22, 2018

This hasn’t been responded to in a long while, so I’m going to mark it as stale. Please feel free to continue the conversation and I’ll reopen.

0reactions
varungupta85commented, Aug 17, 2016

@rt2zz Thanks for responding. I am using firebase as the backend for the react-native application. So, it is possible that I may also have similar websocket problem, although I am not sure if I can really control the creation and closing of websockets by firebase. I see that AsyncStorage is backed by json files. I guess I should first check when AsyncStorage closes the files after a read/write. I am thinking AsyncStorage must be caching the open file handles for quick read/write access and we probably end up writing in separate json files after each persist causing the too many files open error.

I have been thinking about adding an alternate storage backend backed by SQLite or Realm if I don’t get to fix the problems as you have suggested.

Read more comments on GitHub >

github_iconTop Results From Across the Web

redux-persist/getStoredState: Error restoring data for key: xxxxx
redux-persist has been working perfectly for me with smaller size state trees, but trying to use it on bigger ones I'm running into...
Read more >
Preserving and Resetting State - React Docs
React keeps track of which state belongs to which component based on their place in the UI tree. You can control when to...
Read more >
State and Jetpack Compose | Android Developers
On this page; State and composition; State in composables; Other supported types of state. Stateful versus stateless. State hoisting; Restoring state in ...
Read more >
ignite-cli - npm
Infinite Red's hottest boilerplate for React Native. ... MobX-React-Lite; TypeScript; AsyncStorage (integrated with MST for restoring state) ...
Read more >
State persistence | React Navigation
import AsyncStorage from '@react-native-async-storage/async-storage'; ... Only restore state if there's no deep link and we're not on web
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found