browser-compat-data icon indicating copy to clipboard operation
browser-compat-data copied to clipboard

api.FileSystemSyncAccessHandle.write - Write success but data is empty

Open linhttbk97 opened this issue 1 year ago • 1 comments

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: image

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

linhttbk97 avatar Jun 20 '24 05:06 linhttbk97

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?

queengooborg avatar Jul 01 '24 07:07 queengooborg

https://drive.google.com/file/d/1LCcVHFoT9b_P8tqGRT5ct9M9vfOFk7zx/view?usp=sharing here is the sample typescript code

linhttbk97 avatar Jul 04 '24 10:07 linhttbk97

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 avatar Jul 04 '24 13:07 queengooborg

@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

linhttbk97 avatar Jul 05 '24 01:07 linhttbk97

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.

Screenshot 2024-07-05 at 19 50 56

queengooborg avatar Jul 06 '24 02:07 queengooborg

I think i could be happen on lower memory (maybe full disk) but I don't know why the QuotaExceededError doesn't throw

linhttbk97 avatar Jul 08 '24 01:07 linhttbk97

It was tested on 3 mac machines, my mac worked normally but other two didn't

linhttbk97 avatar Jul 08 '24 01:07 linhttbk97