-
Notifications
You must be signed in to change notification settings - Fork 51
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
File Store have bad behavior #41
Comments
Can you describe what do you mean? can you provide basic app based on examples from https://github.com/valery-barysok/session-file-store/tree/master/examples ? |
@valery-barysok |
@gamelaster, as i said before it will be helpful if you can create basic app with your issue. You have to understand that just said "I'm sure the problem isn't in my code because it's working before." is not working :) |
In example you must insert an Steam API key, you can generate it here: |
I tried v4.0.0 , v4.4.1 and still not work. But anyway, funny thing is in Linux (node v4.1.1) it's works lol |
i am busy now and still can not dive into this issue. So i will see as soon as can. |
I am also using passport, but I am not actually using their functionality to serialize/deserialize user information. Instead, after successful login, I look up the user in my local database, and attach information by hand to the However, I am also seeing a ton of:
when a) logging out explicitely and calling |
Try it on Linux |
Im on RHEL5 / MacOS. |
On Linux and OS X this problem is not happend, only Windows |
I had a similar error in Ubuntu, which I solved by following,
instead of ,
|
Same thing here. It seems that the plugin basically tries to load a session file even when it doesn't have to, like when |
thanks. will look on it closely after the new year ) |
@patrickjane Maybe you can just stop logging them if you're sure that's the only problem regarding this plugin by setting |
I'm not sure if this is related or not, if I visit a logout route, then immediately after logging in I would get
And after logging in, something like this:
This is the only code that modifies the session. All I had to do was add the following to logout:
And the problem went away. This is with the following configuration:
Also, this is under windows 10. If you wanted a repro, just use one of the express example, set It seems that the store will be called with destroyed sids if the client still passes along the cookie for a destroyed session - without the I've looked through some of the other session stores and if they don't find anything for the provided sid, they silently invoke the callback function with null. |
@tswaters, please start read from here: #26 (comment). As I remember it is your use case. Basically i can not distinct when ENOENT happens as result of logout and when deletes through retry logic or during renaming of file (by the way, i am going to remove retry logic because file renaming was introduced). |
@rukshn, can you provide reproducible example or just test with store : new Filestore({path : './sessions'}) without |
@patrickjane, can you look at #41 (comment). |
@patrickjane and @tswaters, what if i add emit of error event with some error code that you can ignore instead of log something? |
@gamelaster you said on windows did not work but it does on linux ? can we see your configuration ? |
I have the same problem in window. Not in linux |
#justWindowsThings I believe I have discovered that the issue is connected to the write-file-atomic. Writes to the same file asynchronously are fine on Linux but fail on Windows due to the nature of the POSIX rename. I just recently made a PR to (hopefully) fix this and it's included in [email protected]... please give it a try and let me know if those errors are gone! Read about this in my write-up here npm/write-file-atomic#22 It essentially serializes writes to the same file... But honestly I think to totally resolve this, session-file-store must serialize writes for the same session. |
The problem still persists on Windows |
@gamelaster is there any way we could try to reproduce the issue on our end? Last time I worked on this it seemed that multiple writes would be attempted for the same session file, and then the second write would start before the first one was finished, causing the EPERM error. From what you've described this is actually an ENOENT error, but I suspect the issues might still might be related due to the differences in how POSIX rename works in Linux vs Windows. My strategy for figuring out the sequence of events leading to the error was to insert console.log messages when write-file-atomic begins writing to the file, and when it finishes. Looking at the output from that as session-file-store calls write-file-atomic, I pieced together the concurrency issue by looking at the sequence of events. I suggest trying something similar and sharing your results! |
hi |
I am actually facing the same issue as well, and have been trying to fix the bug in my code since 5 days now. The bug is that, I am using session-file-store to store session files, passport for local authentication. But the deserializeUser is not always called while the serializeUser is always successfully called. So upon many attempts to login, at times desesiralizeUser is called so logged in, and at times it is not called again when logged out trying to re-login . And in my log report, I see many times : Especially when I clean everything up and restart my server, the first log messages are a bunch of this: Conclusion: After pulling out my hair for over 5 days to figure out why the deserializeUser logs me in at times and at times not, I have understood that it is because it does not always find a session file to create the needed cookie to log the user in. By the way Im using windows. PS: Please let me know if Im wrong |
I'm going to post here a year later and say that I have the same problem in Ubuntu docker. |
Problem still exists on Windows 10 too |
Getting this issue on WSL2 Ubuntu 18.04. Resolved by changing |
This answer has helped in my case. |
I'm using In my case, user can open many browser tabs. If he logs out, from on tab(the session file will be gone). The other tab will cause But after tried many ways
this error message still shows.
|
Looks like @gamelaster describes two independent issues. Both of them happened in my project. One of them is about Another one is about session object updated after authentication action and not stored. We've used _handleTicket(req, res){
// ... placeholder code where `requestOptions` is defined
const request = this.request_client.request(requestOptions, (response) => {
// ... placeholder code where `body` is defined
response.on('end', () => {
this._validate(body, (err, user, attributes) => {
if (err) {
res.sendStatus(401);
} else {
req.session[this.session_name] = user; // session is updated
req.session.save(() => { // wait for session to be saved before redirect to application
res.redirect(req.session.cas_return_to);
});
}
});
});
});
// ... placeholder code where request.on('error', () => {}) is defined
}, |
Hello,
I'm using File Store to store my sessions. I don't know why, but many times I got error the some jsons not exists. Okay, its have some problem. But bigger problem is the file store not storaging variables (mainly from passport), just it not storage. Any ideas how to trace where is problem?
The text was updated successfully, but these errors were encountered: