Closed
Bug 987682
Opened 10 years ago
Closed 10 years ago
DumpBookmarks() in bookmarks.jsm hangs due to invalid JSON data
Categories
(Testing Graveyard :: TPS, defect)
Testing Graveyard
TPS
Tracking
(firefox29 wontfix, firefox30 fixed, firefox31 fixed)
RESOLVED
FIXED
mozilla31
People
(Reporter: whimboo, Assigned: whimboo)
References
Details
Attachments
(1 file)
2.27 KB,
patch
|
jgriffin
:
review+
lsblakk
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
The DumpBookmarks() method in bookmarks.jsm fails because of a broken promise handling which causes the JSON data to be empty (invalid). That's why an exception gets raised and cb.wait() is never called. http://mxr.mozilla.org/mozilla-central/source/services/sync/tps/extensions/tps/resource/modules/bookmarks.jsm#23 The problem here is that the call to BookmarkJSONUtils.serializeNodeAsJSONToOutputStream() doesn't stop the execution of the task as is should given the yield keyword. So writer.value has still its initial value '', and JSON.parse('') causes an exception. You can see that when adding dump() statements to writer.write() and after the yield line. Marco, do you have an idea what could go wrong here?
Assignee | ||
Updated•10 years ago
|
Flags: needinfo?(mak77)
Comment 1•10 years ago
|
||
By any chance, could we take the opportunity to get rid of this cb.wait()?
Assignee | ||
Comment 2•10 years ago
|
||
TPS is handling everything synchronously. So there is no easy way to do that. Anything else which would help here?
Comment 3•10 years ago
|
||
Why exactly is TPS handling everything synchronously, I wonder?
Assignee | ||
Comment 4•10 years ago
|
||
Jgriffin has written TPS. So he can tell more. As of now we don't have the time to entirely rewrite tps. We have to get all the tests working, and this is somewhat a blocker for me.
Assignee | ||
Comment 5•10 years ago
|
||
Here the minimized code which should return a serialized JSON string for the bookmarks. Instead it is empty. Components.utils.import("resource://gre/modules/BookmarkJSONUtils.jsm"); let writer = { value: "", write: function PlacesItem__dump__write(aStr, aLen) { this.value += aStr; } }; let options = PlacesUtils.history.getNewQueryOptions(); options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS; let query = PlacesUtils.history.getNewQuery(); query.setFolders([PlacesUtils.placesRootId], 1); let root = PlacesUtils.history.executeQuery(query, options).root; root.containerOpen = true; BookmarkJSONUtils.serializeNodeAsJSONToOutputStream(root, writer, true, false).then(() => { window.alert(writer.value); });
Comment 6•10 years ago
|
||
Actually, I would like to completely kill serializeNodeAsJSONToOutputStream API, it sucks and we are not going to spend time on it. In this case looks like you want to just dump all of the bookmarks, basically dump the bookmarks.json... you should then use the new getBookmarksTree() util and json.stringify the bookmarks object out of it
Flags: needinfo?(mak77)
Assignee | ||
Comment 7•10 years ago
|
||
Sounds fair enough. I will remove it. The alternative works perfectly. Thank you Marco!
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Assignee | ||
Comment 8•10 years ago
|
||
This patch fixes the hang and also makes sure that we do not hang anymore in case an exception gets thrown inside of the then method. Given that the output it not that important we should not call cb(ex) but simply log the error message to the console.
Attachment #8396511 -
Flags: review?(jgriffin)
Assignee | ||
Comment 9•10 years ago
|
||
Ups, kill the last sentence. It's not what the patch contains. If you want that please feel free to request. I would be happy with cb(ex) given that it should not fail.
Assignee | ||
Comment 10•10 years ago
|
||
The remaining hangs in cb.wait() I will get fixed in bug 981848.
Blocks: 981848
Comment 11•10 years ago
|
||
Comment on attachment 8396511 [details] [diff] [review] Patch v1 Review of attachment 8396511 [details] [diff] [review]: ----------------------------------------------------------------- It probably makes sense to log the error, but I don't have a strong opinion, since as you said, the error isn't really important to TPS.
Attachment #8396511 -
Flags: review?(jgriffin) → review+
Assignee | ||
Comment 12•10 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/893c003daf13
Assignee | ||
Updated•10 years ago
|
Target Milestone: --- → mozilla31
https://hg.mozilla.org/mozilla-central/rev/893c003daf13
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 14•10 years ago
|
||
Andrei, can you please verify this fix? I would like to get it backported, but I would like to see at least one other confirmation it works correctly. And given that you also have seen this bug yesterday... Thanks.
Comment 15•10 years ago
|
||
I confirm that I don't see any more hangs with this fix.
Assignee | ||
Comment 16•10 years ago
|
||
Comment on attachment 8396511 [details] [diff] [review] Patch v1 [Approval Request Comment] Bug caused by (feature/regressing bug #): None User impact if declined: None, but automated tests will hang Testing completed (on m-c, etc.): yes Risk to taking this patch (and alternatives if risky): None String or IDL/UUID changes made by this patch:None The backport for beta would need a new patch given that the new method used here, will not be available. But for now we are not clear, if we need this backport at all.
Attachment #8396511 -
Flags: approval-mozilla-aurora?
Updated•10 years ago
|
Attachment #8396511 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Assignee | ||
Comment 17•10 years ago
|
||
https://hg.mozilla.org/releases/mozilla-aurora/rev/a84920158dd4
Assignee | ||
Updated•10 years ago
|
Updated•6 years ago
|
Product: Testing → Testing Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•