-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
It seems as if the save() function of the session is not thread-safe.
When the same user invokes
data.session.save(sessionData);
multiple times in a really short time frame, the session file is getting corrupted.
A hacky and easy solution would be to simply use the blocking function to write a file
fs.writeFileSync(fullPath, content, options);
| await fsp.writeFile(fullPath, content, options) |
Otherwise you need to emulate some kind of lock, maybe create a map of pending write promises({[path: string]: Promise<void> | undefined}) and wait if there is already a promise or completely lock the whole function with https://www.npmjs.com/package/async-lock
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels