Closed Bug 1377260 Opened 5 years ago Closed 5 years ago

Error with .getFilesAndDirectories when directory contents are changing, or filesystem_commons.js needs to be updated

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: benjamin, Assigned: baku)

References

Details

Attachments

(1 file)

I introduced an orange in test_worker_basic.html by changing something entirely unrelated. I landed bug 981818 which causes us to save modified prefs soon after they are changed (instead of only at shutdown).

This caused test_worker_basic.html to fail hitting this line:

https://dxr.mozilla.org/mozilla-central/rev/9af23c413a1f8d337b19b4f8450e241e91b71136/dom/filesystem/tests/filesystem_commons.js#68

Because the error was pretty uninformative, I added some additional debugging, and the actual failure is:
22:44:19     INFO - TEST-UNEXPECTED-FAIL | dom/filesystem/tests/test_worker_basic.html | Something went wrong with .getFilesAndDirectories: [Exception... "File error: Not found"  nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "<unknown>"  data: no] 

My theory about this failure is that this test is calling .getFilesAndDirectories on the profile directory, and racing with a pref save. Saving prefs uses the safe file stream, which writes a temporary file (e.g. "prefs.js.tmp13487") and then renames the temporary file atomically over prefs.js. So if you enumerate the files while the temp file exists and then it doesn't exist later, that would throw an error.

Unfortunately I can't reproduce the problem locally, probably due to differences in disk/CPU speed or test setup that make the race less likely.

So a couple questions:
1) is it normal/ok for .getFilesAndDirectories to reject its promise if there are operations happening while its running?
2) should I try and change this test to e.g. use a different directory?
Flags: needinfo?(amarchesini)
> 2) should I try and change this test to e.g. use a different directory?

I just sent a patch with this approach: bug 1360320.

But, at the same time, we should decide what the API should do if the directory changes. Let's keep this bug for a more global approach.
Flags: needinfo?(amarchesini)
Attached patch fs_change.patchSplinter Review
Assignee: nobody → amarchesini
Attachment #8882408 - Flags: review?(bugs)
Attachment #8882408 - Flags: review?(bugs) → review+
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/006ce2d73568
Entries API must return results also when the underlying files of a directory change, r=smaug
https://hg.mozilla.org/mozilla-central/rev/006ce2d73568
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.