api.FileSystemSyncAccessHandle.write - Write success but data is empty
What type of issue is this?
Other
What information was incorrect, unhelpful, or incomplete?
I use "write" file api on safari 16.1 ( macos 13.0.1) to write simple 10 bytes of data with OPFS.
The write function return result as success but then I read that file again, my data is gone.
here is the code: https://paste.ofcode.org/EwFFxySvNFecnb28VNcMyc
and here is the console log:
What browsers does this problem apply to, if applicable?
Safari
What did you expect to see?
When I read that file again, I can see my data
Did you test this? If so, how?
Sure, I test this on two macos ( safari 16.1 and safari 16.5)
Can you link to any release notes, bugs, pull requests, or MDN pages related to this?
No response
Do you have anything more you want to share?
No response
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write
MDN metadata
MDN page report details
- Query:
api.FileSystemSyncAccessHandle.write - Report started: 2024-06-20T04:55:22.297Z
I'm afraid that the code example you provided is not available. Could you please provide the code once again, perhaps directly in a comment here?
https://drive.google.com/file/d/1LCcVHFoT9b_P8tqGRT5ct9M9vfOFk7zx/view?usp=sharing here is the sample typescript code
Thanks for providing the sample code! I added it directly to your original message and converted it from TypeScript to pure JavaScript to simplify the test.
Looking at the code, I see that you create the sync access handle, you flush it, and then you close it. But you don't actually write any data; sampleData is unused in this function.
As a result, I'm going to close this issue as it's a development issue, rather than a browser issue.
@queengooborg No,I deleted it when copying, my mistake. Pls reopen this issue I just updated code and provide console log. I try to read "test.db" file again and see file size is 0 byte after write sampleData
I just took another look, this time attempting to run the code provided (after converting it from TypeScript again -- FYI, for ease of testing, you should always provide pure JavaScript examples in test code, unless there's an absolute need to use TypeScript in the example), and I've found that the contents of the file have been written properly in Safari 16.5 and 17.5, as well as Chrome 126.
I think i could be happen on lower memory (maybe full disk) but I don't know why the QuotaExceededError doesn't throw
It was tested on 3 mac machines, my mac worked normally but other two didn't