Closed dougtaylor-cb closed 6 years ago
I found the problem.
The node-localstorage module uses a different location in debug mode. In debug mode, it was saving to the same path as the package.json file, but in live mode it was using the path of the server.js file.
The reason why I was getting an empty string as a response is because the data I was testing with had been built in debug mode, and did not exist in the path the live mode was using.
Building the data in live mode resolved the issue, but this may be something you want to look into further.
Hmmm, glad you figured it out. You can also specify the location when you instantiate.
localStorage = new LocalStorage('./scratch')
I'm using the code below in my node server. The first module is what handles the GET request, and the second one deals with localStorage. If I run the server in debug mode, everything works fine. Data is pulled from localStorage and then passed on to the source that made the GET request. If I run the server in live mode, localStorage fails to return any data at all. In this case, return false; is not called, nor is the catch block triggered, and even console.log('the localstorage if statement failed to run'); isn't called. The data being pulled from localStorage is about 1.5mb.
For example, if I'm in debug mode and I trigger the getTime function, my console shows this:
If I run it in live and do the same thing, I get this:
I tried making these async functions and using await, under the assumption that the problem was a delay in pulling the data from the file used for storage, but had the same results then.