Skip to content

Commit

Permalink
fix: tester startup should not block other plugin startup
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Dec 9, 2024
1 parent 6bac5e2 commit 3f2c76d
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions src/core/tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,43 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
["content", "${this._testPluginRef}", rootURI + "content/"],
]);
launchTests().catch((error) => {
Zotero.debug(error);
Zotero.HTTP.request(
"POST",
"http://localhost:${this.ctx.test.port || 9876}/update",
{
body: JSON.stringify({
type: "fail",
data: {
title: "Internal: Plugin awaiting timeout",
stack: "",
str: "Plugin awaiting timeout",
},
}),
}
);
});
}
function onMainWindowLoad({ window: win }) {}
function onMainWindowUnload({ window: win }) {}
function shutdown({ id, version, resourceURI, rootURI }, reason) {
if (reason === APP_SHUTDOWN) {
return;
}
if (chromeHandle) {
chromeHandle.destruct();
chromeHandle = null;
}
}
function uninstall(data, reason) {}
async function launchTests() {
// Delay to allow plugin to fully load before opening the test page
await Zotero.Promise.delay(${this.ctx.test.startupDelay || 1000});
Expand All @@ -192,20 +229,6 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
return false;
}
}).catch(() => {
Zotero.HTTP.request(
"POST",
"http://localhost:${this.ctx.test.port || 9876}/update",
{
body: JSON.stringify({
type: "fail",
data: {
title: "Internal: Plugin awaiting timeout",
stack: "",
str: "Plugin awaiting timeout",
},
}),
}
);
throw new Error("Plugin awaiting timeout");
});
}
Expand All @@ -219,23 +242,6 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
);
}
function onMainWindowLoad({ window: win }) {}
function onMainWindowUnload({ window: win }) {}
function shutdown({ id, version, resourceURI, rootURI }, reason) {
if (reason === APP_SHUTDOWN) {
return;
}
if (chromeHandle) {
chromeHandle.destruct();
chromeHandle = null;
}
}
function uninstall(data, reason) {}
function waitUtilAsync(condition, interval = 100, timeout = 1e4) {
return new Promise((resolve, reject) => {
const start = Date.now();
Expand Down

0 comments on commit 3f2c76d

Please sign in to comment.