Community
Participate
Working Groups
In FF4/firebug I see -- SyntaxError: JSON.parse return projectsPref ? JSON.parse(projectsPref) : null; -- line 50 (index.html) I don't think we're handling settting/getting projectsPref correctly.
This code has worked in the past, but it seems like something weird is going on when the preferences are cleared. I stepped through it and appears to me that there is some gibberish being returned by the prefs service. This is the code: serviceRegistry.getService("orion.core.preference").then(function(service) { return service.getPreferences("/window/recent"); }).then(function(prefs){ var projectsPref = prefs.get("projects"); return projectsPref ? JSON.parse(projectsPref) : null; The "prefs" returned by getPreferences("/window/recent") is an empty object, { } Not too surprising if there are no values there. But then the request prefs.get("projects"); returns this: "["8","\"","}","]" So the attempt to parse it fails. Where did this string come from? The code assumes that if there is something returned by prefs.get("projects") that it is valid json. I then navigated to a project (so that a new location would be set in this preference). Then the preference node value is: "["8","\"","}","]",{"location":"/file/e/?depth=1","name":"m8"}]" That second value looks good. So the question is, where is that first string coming from for the empty pref node. I think this is a prefs service bug????
The projects pref in this case does not need to be parsed as the preferences service has already done that and the setter did not stringify the perferences prior to setting them. I have a small patch for review. I manually cleared my old user preferences and no longer have problems but I would like to try this in a clean build to make sure I am really getting this problem.
I'm no longer seeing the parse error but when walking through with the debugger am still seeing something like [""","}","]", ...correct project json...]. I'll dig further here as something is clearly messed up and will eventually come back to bite us.
There is a problem in the PreferencesServlet where we are ending up losing JSON type information when we serialize our values as strings. When we go to re-get them we always treat them as strings. I'm not sure if this is by design but I don't think we want to change this right now. Favorites.js is using a check to determine if a preference has been returned as a string and if so will JSON.parse it. This is why favorites has never been broken. I've made it so the "/windows/recent/projects" preference uses the same logic. I'll open a separate bug to figure out what we want to do server-side.
Fixed in HEAD. Mark reviewed this latest fix.