Skip to content

No explicit file lock release when write() throws an exception #153

@saschanaz

Description

@saschanaz

What is the issue with the File System Standard?

https://fs.spec.whatwg.org/#write-a-chunk throws when getting a non-FileSystemWriteChunkType:

Let input be the result of converting chunk to a FileSystemWriteChunkType. If this throws an exception, then return a promise rejected with that exception.

But the spec does not say whether this exception should release the lock. In fact, the release only happens within:

  1. closeAlgorithm (step 4.2.2.4.1 in https://fs.spec.whatwg.org/#create-a-new-filesystemwritablefilestream)
  2. abortAlgorithm (step 5.1.1 in https://fs.spec.whatwg.org/#create-a-new-filesystemwritablefilestream)
  3. close() method (https://fs.spec.whatwg.org/#dom-filesystemsyncaccesshandle-close)

Errors from writeAlgorithm does not release the lock at all per the spec, as returning a rejected promise is not enough, which leads to a permanent lock as there's no GC-triggered lock release either.

The FS spec probably can get some algorithm to return a promise that waits for the lock release and use it for each exception, but that's sad as the implementations should do extra care for every implementation-specific error conditions. Could be nice if the Streams spec had some async hook to handle the error.

cc @jjjalkanen
cc @domenic @MattiasBuelens

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions