11

I'm using node with the express-session and session-file-store packages. The session data is stored as files in the root directory, using the session-file-store package. However, now my logs are being clogged because the message [session-file-store] will retry, error on last attempt: Error: ENOENT, open 'sessions/_jl2ijMBQHIvv8M1mYTcnFZGqwGo0t-v.json' is appearing 5 times per session cookie accessed in a short burst. What could be causing this error? It's happening both on my windows development machine and on my ubuntu server. It can't access the file apparently, but the sessions still work.

Here is one of the bursts of errors I received:

[session-file-store] will retry, error on last attempt: Error: ENOENT, open 'sessions/tRI6WeZEO2Uyvr4ZaUGW6_CU32RjvFpW.json'
[session-file-store] will retry, error on last attempt: Error: ENOENT, open 'sessions/tRI6WeZEO2Uyvr4ZaUGW6_CU32RjvFpW.json'
[session-file-store] will retry, error on last attempt: Error: ENOENT, open 'sessions/tRI6WeZEO2Uyvr4ZaUGW6_CU32RjvFpW.json'
[session-file-store] will retry, error on last attempt: Error: ENOENT, open 'sessions/tRI6WeZEO2Uyvr4ZaUGW6_CU32RjvFpW.json'
[session-file-store] will retry, error on last attempt: Error: ENOENT, open 'sessions/tRI6WeZEO2Uyvr4ZaUGW6_CU32RjvFpW.json'

3 Answers 3

14

So I literally just ran into the same messages when I was trying my first NodeJS/Express Sample Project out.

I managed to determine that at least in my sample project that the Session is Declared Destroyed but the Cookie never cleared, so the next page that loaded used the old cookie to try and access the expired session (already deleted) causing the messages to get logged.

This might not be the same issue for you, but figured it was worth sharing... The lazy alternative is to replace the logFn option with an empty function:

new filestore({logFn: function(){}})
1
  • 5
    Another solution: use option session-file-store option retries: 0: it will give up on unknown sessions without retrying. In most use cases (local filesystem), retrying is useless. Jan 9, 2019 at 15:04
2

In my case that has not been as main problem, because session-file-store is a part of express-session and when express-session can't find session file, he just create new file.

And then you can just hide errors log as suggested earlier

new filestore({logFn: function(){}})
0

I was able to solve the same problem by chmod +x sessions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.