Skip to content

Commit

Permalink
Fix fallout from bug 1771463 and show errors during initializtion (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhammond authored Jun 9, 2022
1 parent d9f0681 commit 4173bdf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"applications": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "72.0a1"
"strict_min_version": "103.0a1"
}
},

Expand Down
3 changes: 2 additions & 1 deletion src/CollectionsViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const collectionComponentBuilders = {
},

async clients(provider, serverRecords) {
const fxAccounts = importLocal("resource://gre/modules/FxAccounts.jsm").fxAccounts;
const { getFxAccountsSingleton } = importLocal("resource://gre/modules/FxAccounts.jsm");
const fxAccounts = getFxAccountsSingleton();
let fxaDevices = [];
if (typeof fxAccounts.device == "object" && "recentDeviceList" in fxAccounts.device) {
// Force a refresh of the device list, so that we always show the most
Expand Down
12 changes: 12 additions & 0 deletions src/common.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ErrorDisplay extends React.Component {
onClose: PropTypes.func,
prefix: PropTypes.string,
formatError: PropTypes.func,
stack: PropTypes.func,
error: PropTypes.any,
};
}
Expand All @@ -93,6 +94,7 @@ class ErrorDisplay extends React.Component {
return {
prefix: "Error: ",
formatError: ErrorDisplay.defaultFormatter,
stack: ErrorDisplay.stack
};
}

Expand All @@ -111,6 +113,9 @@ class ErrorDisplay extends React.Component {
{this.props.prefix}
{this.props.formatError(this.props.error)}
</p>
<pre>
{this.props.stack(this.props.error)}
</pre>
</div>
);
}
Expand All @@ -125,6 +130,13 @@ class ErrorDisplay extends React.Component {
}
return result;
}

static stack(err) {
if (err && err.stack) {
return err.stack;
}
return "<no stack available>";
}
}

// Like Async.jankYielder, but without adding another Cu.import, and uses the
Expand Down
12 changes: 11 additions & 1 deletion src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ const { CollectionsViewer } = require("./CollectionsViewer");
const { ErrorDisplay, Fetching, importLocal } = require("./common");

const { Services } = importLocal("resource://gre/modules/Services.jsm");
const { fxAccounts } = importLocal("resource://gre/modules/FxAccounts.jsm");
const { Weave } = importLocal("resource://services-sync/main.js");

const weaveService = Cc["@mozilla.org/weave/service;1"]
.getService(Ci.nsISupports)
.wrappedJSObject;

const { getFxAccountsSingleton } = importLocal("resource://gre/modules/FxAccounts.jsm");
const fxAccounts = getFxAccountsSingleton();

// Returns a promise that resolves when Sync is ready and logged in.
function whenSyncReady() {
return weaveService.whenLoaded().then(() => {
Expand Down Expand Up @@ -97,6 +99,7 @@ class AboutSyncComponent extends React.Component {
provider: ProviderState.newProvider(),
});
}).catch(e => {
console.error("Failed to load initial state", e);
this.setState({error: e})
})
}
Expand All @@ -109,6 +112,13 @@ class AboutSyncComponent extends React.Component {

render() {
let loginState = this.state.ready ? String(this.state.loggedIn) : "unknown";
if (this.state && this.state.error) {
return (
<ErrorDisplay error={this.state.error}
prefix="Failed to initialize"/>
);
}

return (
<div className="mainContainer">
<div hidden={this.state.ready}>
Expand Down

0 comments on commit 4173bdf

Please sign in to comment.