Skip to content

The library seems to not be multithread safe #102

@oltreseba

Description

@oltreseba

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions