Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails silently when using bad path #464

Open
elliotsayes opened this issue Oct 20, 2022 · 4 comments
Open

Fails silently when using bad path #464

elliotsayes opened this issue Oct 20, 2022 · 4 comments

Comments

@elliotsayes
Copy link
Contributor

When creating MMKV with a bad path e.g.

const storage = new MMKV({
  id: 'storage',
  path: '/someillegalpath/data',
})

This call succeeds

storage.put('myKey', 'some data')

However the data is not actually stored

console.log(storage.getString('myKey'))
// LOG: undefined

As an aside would be nice to have some examples with valid paths or link to docs about what paths are allowed :)
Or maybe export DocumentDir or something like react-native-fs?

@mrousavy
Copy link
Owner

Oh that's interesting. Is there something being printed to Xcode Logs / Android Logcat?

@elliotsayes
Copy link
Contributor Author

Ahh yes there is:

2022-10-25 10:29:26.434695+1300 Evertrove[99366:6190752] [W] <MemoryFile.cpp:273::mkPath> /mybadpath : Read-only file system
2022-10-25 10:29:26.434864+1300 Evertrove[99366:6190752] [I] <MMKV.cpp:234::mmkvWithID> prepare to load mmkv.default (id 0306af51b6f09612686a6fec90b5c7a7) from rootPath /mybadpath/file
2022-10-25 10:29:26.434977+1300 Evertrove[99366:6190752] [E] <MemoryFile.cpp:94::open> fail to open [/mybadpath/file/mmkv.default], 2(No such file or directory)
2022-10-25 10:29:26.435093+1300 Evertrove[99366:6190752] [E] <MemoryFile.cpp:94::open> fail to open [/mybadpath/file/mmkv.default], 2(No such file or directory)
2022-10-25 10:29:26.435196+1300 Evertrove[99366:6190752] [E] <MemoryFile.cpp:208::reloadFromFile> fail to open:/mybadpath/file/mmkv.default, Undefined error: 0
2022-10-25 10:29:26.435316+1300 Evertrove[99366:6190752] [E] <MemoryFile.cpp:94::open> fail to open [/mybadpath/file/mmkv.default.crc], 2(No such file or directory)
2022-10-25 10:29:26.435411+1300 Evertrove[99366:6190752] [E] <MemoryFile.cpp:94::open> fail to open [/mybadpath/file/mmkv.default.crc], 2(No such file or directory)
2022-10-25 10:29:26.435481+1300 Evertrove[99366:6190752] [E] <MemoryFile.cpp:208::reloadFromFile> fail to open:/mybadpath/file/mmkv.default.crc, Undefined error: 0
2022-10-25 10:29:26.435575+1300 Evertrove[99366:6190752] [E] <MemoryFile.cpp:94::open> fail to open [/mybadpath/file/mmkv.default], 2(No such file or directory)
2022-10-25 10:29:26.435655+1300 Evertrove[99366:6190752] [E] <MemoryFile.cpp:208::reloadFromFile> fail to open:/mybadpath/file/mmkv.default, Undefined error: 0
2022-10-25 10:29:26.438928+1300 Evertrove[99366:6190752] [E] <MMKV_IO.cpp:74::loadFromFile> file [/mybadpath/file/mmkv.default] not valid
2022-10-25 10:29:26.441086+1300 Evertrove[99366:6190752] [javascript] { '0': 104,
  '1': 105,
  '2': 32,
  '3': 128,
  '4': 104,
  '5': 101,
  '6': 114,
  '7': 101 }
2022-10-25 10:29:26.441316+1300 Evertrove[99366:6190752] [W] <MMKV_IO.cpp:346::ensureMemorySize> [mmkv.default] file not valid
2022-10-25 10:29:26.442056+1300

I'll pay more attention to the iOS log when debugging 🕵️‍♂️ Still would be nice to see these bubble up to the JS log

@mrousavy
Copy link
Owner

Still would be nice to see these bubble up to the JS log

No, lol that would be pretty annoying as it spams a lot. A native library logs to the native console.

fail to open [/mybadpath/file/mmkv.default], 2(No such file or directory)

But yea that's weird. I wonder why that doesn't throw.

@mrousavy
Copy link
Owner

Does this issue still persist?

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

No branches or pull requests

3 participants
@elliotsayes @mrousavy and others