Skip to content

[BUG] <The library seems to not be safe with multiple webworkers> #57

Open
@oltreseba

Description

@oltreseba

What / Why

With reference with the following but sindresorhus/conf#102, it appears that in a multiple webworker environment the library may have problems.
I'm working inside an electron app.

What is happening when multiple webworkers try to write the same file:

  • 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, at least in an electron environment)
  • 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 an exception.

I'm getting the following exception:

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

When

This happen when i try to write the same file from multiple webworkers. It may not happen always since it's related with multithreading.

Where

writeFileSync function. But probably writeFile has the same problem?

How

Current Behavior

The function throw an exception when attempting to write a not-exiting file.

Steps to Reproduce

Start multiple workers that write to the same file.

Expected Behavior

The file access should be piped probably?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions