Synchronous FS on web

I've previously considered using the File System API from the Web APIs, specifically the origin private file system (OPFS) that allows operating on files that belong to the current page or document's origin.

The limitations I've found after iterating the MDN documentation is that obtaining directory handles through OPFS passes through promises and furthermore there are no synchronous operations at all. Also, there are synchronous file handles, but no synchronous directory handles.

Other considerations:

  • Cookies: Since they are simply a string (document.cookies IIRC), you've to build a directory hierarchy manually using some string notation.
  • IndexedDB: All operations are asynchronous as I understand it.

Should I simply not support the web properly in my file API and map it to RAM memory instead for now?

There is not enough information about what you are doing in this post to answer that. But my understanding is that web browsers completely forbid any operation that may block in the main thread. If you want to run in the browser you have to play by their rules. If you want to support that or not is up to you and your use case.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.