diff --git a/.github/workflows/publish-plugin.yml b/.github/workflows/publish-plugin.yml index 7a168db5..9e74c60d 100644 --- a/.github/workflows/publish-plugin.yml +++ b/.github/workflows/publish-plugin.yml @@ -3,7 +3,7 @@ name: Publish Obsidian plugin on: push: tags: ["*"] -pull_request: + pull_request: branches: ["main"] env: diff --git a/frontend/test-client/src/agent/mock-agent.ts b/frontend/test-client/src/agent/mock-agent.ts index 13d9928a..1640c2ec 100644 --- a/frontend/test-client/src/agent/mock-agent.ts +++ b/frontend/test-client/src/agent/mock-agent.ts @@ -90,10 +90,11 @@ export class MockAgent extends MockClient { this.createFileAction.bind(this) ]; - if (this.client.getSettings().isSyncEnabled) { - if (this.doNotTouchWhileOffline.length === 0) { - options.push(this.disableSyncAction.bind(this)); - } + if ( + this.client.getSettings().isSyncEnabled && + this.doNotTouchWhileOffline.length === 0 + ) { + options.push(this.disableSyncAction.bind(this)); } else { options.push(this.enableSyncAction.bind(this)); } diff --git a/frontend/test-client/src/cli.ts b/frontend/test-client/src/cli.ts index b5370d0b..3af547e7 100644 --- a/frontend/test-client/src/cli.ts +++ b/frontend/test-client/src/cli.ts @@ -10,12 +10,15 @@ const TEST_ITERATIONS = 5; // Simulate async file access by injecting waiting time before returning from file operations. let slowFileEvents = false; +// Whether to do resets in the test runs +let doResets = false; + async function runTest({ agentCount, concurrency, iterations, doDeletes, - doResets, + useResets, useSlowFileEvents, jitterScaleInSeconds }: { @@ -23,13 +26,14 @@ async function runTest({ concurrency: number; iterations: number; doDeletes: boolean; - doResets: boolean; + useResets: boolean; useSlowFileEvents: boolean; jitterScaleInSeconds: number; }): Promise { slowFileEvents = useSlowFileEvents; + doResets = useResets; - const settings = `with ${agentCount} agents, concurrency ${concurrency}, iterations ${iterations}, doDeletes ${doDeletes}, doResets ${doResets}, jitterScaleInSeconds ${jitterScaleInSeconds}, useSlowFileEvents ${useSlowFileEvents}`; + const settings = `with ${agentCount} agents, concurrency ${concurrency}, iterations ${iterations}, doDeletes ${doDeletes}, doResets ${useResets}, jitterScaleInSeconds ${jitterScaleInSeconds}, useSlowFileEvents ${useSlowFileEvents}`; console.info(`Running test ${settings}`); const vaultName = uuidv4(); @@ -49,7 +53,7 @@ async function runTest({ initialSettings, `agent-${i}`, doDeletes, - doResets, + useResets, useSlowFileEvents, jitterScaleInSeconds ) @@ -118,6 +122,16 @@ async function runTest({ async function runTests(): Promise { for (let i = 0; i < TEST_ITERATIONS; i++) { + await runTest({ + agentCount: 2, + concurrency: 16, + iterations: 100, + doDeletes: true, + useResets: true, + useSlowFileEvents: true, + jitterScaleInSeconds: 0.75 + }); + for (const useSlowFileEvents of [true, false]) { for (const concurrency of [ 16, @@ -129,23 +143,13 @@ async function runTests(): Promise { concurrency, iterations: 100, doDeletes, - doResets: false, + useResets: false, useSlowFileEvents, jitterScaleInSeconds: 0.75 }); } } } - - await runTest({ - agentCount: 2, - concurrency: 16, - iterations: 100, - doDeletes: true, - doResets: true, - useSlowFileEvents: true, - jitterScaleInSeconds: 0.75 - }); } } @@ -177,6 +181,16 @@ process.on("unhandledRejection", (error, _promise) => { return; } + if ( + doResets && + error instanceof Error && + error.message.includes( + "SyncClient has been destroyed and can no longer be used" + ) + ) { + return; + } + console.error("Unhandled rejection:", error); process.exit(1); });