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

The library seems to not be multithread safe #102

Closed
oltreseba opened this issue Jan 29, 2020 · 2 comments
Closed

The library seems to not be multithread safe #102

oltreseba opened this issue Jan 29, 2020 · 2 comments

Comments

@oltreseba
Copy link

oltreseba commented Jan 29, 2020

I'm using conf inside in an electron application inside some webworkers.

The reason why i'm not using electron-store is that it does not work in webworkers.

conf seems to have problem in initialising the config file from different webworkers. The underlying problem seems to be related with the write-file-atomic package, function writeFileSync

What is it doing: (i assume for avoiding having corrupted files)

  • creating a tmp config file
  • writing in the file
  • renaming it

What can happen in a multithread environment:

  • Webworker 1 -> create tmp file
  • Webworker 2 -> create same tmp file (apparently the file name depends on the pid, which is the same from all the webworkers)
  • Webworker 1 -> set file permission, write the file and delete it
  • Webworker 2 -> set file permission, but cannot since the file does not exists anymore. And throw and exception.

The exception i'm getting is:

ENOENT: no such file or directory, chown '/Users/oltreseba/Library/Preferences/project-nodejs/config.json.1638900804'
@sindresorhus
Copy link
Owner

I would recommend opening an issue on write-file-atomic about this. It should support Webworkers.

@oltreseba
Copy link
Author

Right. Done.

sindresorhus added a commit that referenced this issue Mar 16, 2022
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

2 participants