Commit 8983aba1 authored by Robert Knight's avatar Robert Knight

Call PortProvider.listen sooner

Call `listen` immediately after creating the PortProvider, before
creating the sidebar.

This will allow us to rule out the possibility that the sidebar sometimes fails
to connect to the PortProvider because an error occurred in the annotator code
after creating the sidebar iframe but before calling `PortProvider.listen`,
resulting in the PortProvider listener not being created.
parent 62e9ea2e
...@@ -53,6 +53,7 @@ function init() { ...@@ -53,6 +53,7 @@ function init() {
const hypothesisAppsOrigin = new URL(sidebarConfig.sidebarAppUrl).origin; const hypothesisAppsOrigin = new URL(sidebarConfig.sidebarAppUrl).origin;
portProvider = new PortProvider(hypothesisAppsOrigin); portProvider = new PortProvider(hypothesisAppsOrigin);
portProvider.listen();
sidebar = new Sidebar(document.body, eventBus, guest, sidebarConfig); sidebar = new Sidebar(document.body, eventBus, guest, sidebarConfig);
notebook = new Notebook(document.body, eventBus, getConfig('notebook')); notebook = new Notebook(document.body, eventBus, getConfig('notebook'));
...@@ -60,8 +61,6 @@ function init() { ...@@ -60,8 +61,6 @@ function init() {
portProvider.on('frameConnected', (source, port) => portProvider.on('frameConnected', (source, port) =>
sidebar.onFrameConnected(source, port) sidebar.onFrameConnected(source, port)
); );
portProvider.listen();
} }
sidebarLinkElement.addEventListener('destroy', () => { sidebarLinkElement.addEventListener('destroy', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment