From 23405c9897f354750d589962ecb130ee7ca988aa Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Tue, 24 Oct 2023 15:04:09 +0200 Subject: [PATCH 01/16] Callbacks for client reset have been restored --- CHANGELOG.md | 4 +-- .../tests/src/tests/sync/client-reset.ts | 33 ++++++++++++------- .../src/utils/ExtendedAppConfigBuilder.ts | 2 +- packages/realm/bindgen/js_opt_in_spec.yml | 3 ++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 974e4a4754..1558ceaff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,7 @@ * None ### Fixed -* ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) -* None +* Callbacks during client reset were not called. ([#6201](https://github.com/realm/realm-js/issues/6201), since v12.0.0) ### Compatibility * React Native >= v0.71.4 @@ -19,6 +18,7 @@ +* Some disabled tests for client reset (partition based sync) have been abled. ([#6201](https://github.com/realm/realm-js/issues/6201) ## 12.2.1 (2023-10-05) diff --git a/integration-tests/tests/src/tests/sync/client-reset.ts b/integration-tests/tests/src/tests/sync/client-reset.ts index b8f5c8b09c..bbbf022d71 100644 --- a/integration-tests/tests/src/tests/sync/client-reset.ts +++ b/integration-tests/tests/src/tests/sync/client-reset.ts @@ -54,7 +54,17 @@ function getPartitionValue() { } async function triggerClientReset(app: App, user: User): Promise { - await user.functions.triggerClientReset(app.id, user.id); + const maxAttempts = 5; + let deleted = false; + let count = maxAttempts; + while (count > 0) { + deleted = await user.functions.triggerClientReset(app.id, user.id) as boolean; + if (deleted) { + return; + } + count--; + } + throw new Error(`Cannot trigger client reset in ${maxAttempts} attempts`); } async function waitServerSideClientResetDiscardUnsyncedChangesCallbacks( @@ -194,8 +204,8 @@ async function waitSimulatedClientResetDiscardUnsyncedChangesCallbacks( if (useFlexibleSync) { addSubscriptions(realm); } - await realm.syncSession?.uploadAllLocalChanges(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore calling undocumented method _simulateError realm.syncSession?._simulateError(211, "Simulate Client Reset", "realm::sync::ProtocolError", false); // 211 -> diverging histories @@ -226,7 +236,7 @@ async function waitSimulatedClientResetRecoverCallbacks( afterCalled = true; actionAfter(before, after); if (beforeCalled) { - resetHandle.resolve(); + resetHandle.resolve(); } }, onBefore: (realm: Realm) => { @@ -283,7 +293,7 @@ function getSchema(useFlexibleSync: boolean) { } // FIXME: testing flexible sync is currently disabled as it is timing out -[false /*, true*/].forEach((useFlexibleSync) => { +[false/*, true*/].forEach((useFlexibleSync) => { describe.skipIf( environment.missingServer, `client reset handling (${getPartialTestTitle(useFlexibleSync)} sync)`, @@ -291,8 +301,8 @@ function getSchema(useFlexibleSync: boolean) { this.longTimeout(); // client reset with flexible sync can take quite some time importAppBefore( useFlexibleSync - ? buildAppConfig("with-flx").anonAuth().flexibleSync() - : buildAppConfig("with-pbs").anonAuth().partitionBasedSync(), + ? buildAppConfig("with-flx").anonAuth().flexibleSync().triggerClientResetFunction() + : buildAppConfig("with-pbs").anonAuth().partitionBasedSync().triggerClientResetFunction(), ); authenticateUserBefore(); @@ -417,7 +427,7 @@ function getSchema(useFlexibleSync: boolean) { }); }); - it.skip(`client reset fails, the error handler is called (${getPartialTestTitle( + it(`client reset fails, the error handler is called (${getPartialTestTitle( useFlexibleSync, )})`, async function (this: RealmContext) { // if client reset fails, the error handler is called @@ -456,9 +466,10 @@ function getSchema(useFlexibleSync: boolean) { }); }); - it.skip(`handles discard local simulated client reset with ${getPartialTestTitle( + it(`handles discard local simulated client reset with ${getPartialTestTitle( useFlexibleSync, )} sync enabled`, async function (this: RealmContext) { + this.timeout(120 * 1000); // (i) using a client reset in "DiscardUnsyncedChanges" mode, a fresh copy // of the Realm will be downloaded (resync) // (ii) two callback will be called, while the sync error handler is not @@ -481,7 +492,7 @@ function getSchema(useFlexibleSync: boolean) { ); }); - it.skip(`handles simulated client reset with recovery with ${getPartialTestTitle( + it(`handles simulated client reset with recovery with ${getPartialTestTitle( useFlexibleSync, )} sync enabled`, async function (this: RealmContext) { const clientResetBefore = (realm: Realm): void => { @@ -501,7 +512,7 @@ function getSchema(useFlexibleSync: boolean) { ); }); - it.skip(`handles discard local client reset with ${getPartialTestTitle( + it(`handles discard local client reset with ${getPartialTestTitle( useFlexibleSync, )} sync enabled`, async function (this: RealmContext) { // (i) using a client reset in "DiscardUnsyncedChanges" mode, a fresh copy @@ -527,7 +538,7 @@ function getSchema(useFlexibleSync: boolean) { ); }); - it.skip(`handles recovery client reset with ${getPartialTestTitle( + it(`handles recovery client reset with ${getPartialTestTitle( useFlexibleSync, )} sync enabled`, async function (this: RealmContext) { // (i) using a client reset in "Recovery" mode, a fresh copy diff --git a/integration-tests/tests/src/utils/ExtendedAppConfigBuilder.ts b/integration-tests/tests/src/utils/ExtendedAppConfigBuilder.ts index bfa9b28ca5..8fd3c8d84f 100644 --- a/integration-tests/tests/src/utils/ExtendedAppConfigBuilder.ts +++ b/integration-tests/tests/src/utils/ExtendedAppConfigBuilder.ts @@ -178,7 +178,7 @@ export class ExtendedAppConfigBuilder extends AppConfigBuilder { } triggerClientResetFunction() { - this.function({ + return this.function({ name: "triggerClientReset", private: false, run_as_system: true, diff --git a/packages/realm/bindgen/js_opt_in_spec.yml b/packages/realm/bindgen/js_opt_in_spec.yml index 57e15cdfee..c394069606 100644 --- a/packages/realm/bindgen/js_opt_in_spec.yml +++ b/packages/realm/bindgen/js_opt_in_spec.yml @@ -77,6 +77,9 @@ records: - ssl_verify_callback - cancel_waits_on_nonfatal_error - proxy_config + - client_resync_mode + - notify_before_client_reset + - notify_after_client_reset SyncProxyConfig: fields: From dd6ae679427b3a025c05dc313fa3265f58b7d582 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Thu, 26 Oct 2023 15:31:02 +0200 Subject: [PATCH 02/16] Apply suggestions from code review Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com> --- CHANGELOG.md | 4 ++-- integration-tests/tests/src/tests/sync/client-reset.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1558ceaff5..fa216022e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * None ### Fixed -* Callbacks during client reset were not called. ([#6201](https://github.com/realm/realm-js/issues/6201), since v12.0.0) +* The `onBefore`, `onAfter`, and `onFallback` client reset callbacks were not called. ([#6201](https://github.com/realm/realm-js/issues/6201), since v12.0.0) ### Compatibility * React Native >= v0.71.4 @@ -18,7 +18,7 @@ -* Some disabled tests for client reset (partition based sync) have been abled. ([#6201](https://github.com/realm/realm-js/issues/6201) +* Some disabled tests for client reset (partition based sync) have been enabled. ([#6201](https://github.com/realm/realm-js/issues/6201) ## 12.2.1 (2023-10-05) diff --git a/integration-tests/tests/src/tests/sync/client-reset.ts b/integration-tests/tests/src/tests/sync/client-reset.ts index bbbf022d71..1b5b430760 100644 --- a/integration-tests/tests/src/tests/sync/client-reset.ts +++ b/integration-tests/tests/src/tests/sync/client-reset.ts @@ -58,7 +58,7 @@ async function triggerClientReset(app: App, user: User): Promise { let deleted = false; let count = maxAttempts; while (count > 0) { - deleted = await user.functions.triggerClientReset(app.id, user.id) as boolean; + deleted = (await user.functions.triggerClientReset(app.id, user.id)) as boolean; if (deleted) { return; } @@ -236,7 +236,7 @@ async function waitSimulatedClientResetRecoverCallbacks( afterCalled = true; actionAfter(before, after); if (beforeCalled) { - resetHandle.resolve(); + resetHandle.resolve(); } }, onBefore: (realm: Realm) => { @@ -293,7 +293,7 @@ function getSchema(useFlexibleSync: boolean) { } // FIXME: testing flexible sync is currently disabled as it is timing out -[false/*, true*/].forEach((useFlexibleSync) => { +[false /*, true*/].forEach((useFlexibleSync) => { describe.skipIf( environment.missingServer, `client reset handling (${getPartialTestTitle(useFlexibleSync)} sync)`, @@ -301,7 +301,7 @@ function getSchema(useFlexibleSync: boolean) { this.longTimeout(); // client reset with flexible sync can take quite some time importAppBefore( useFlexibleSync - ? buildAppConfig("with-flx").anonAuth().flexibleSync().triggerClientResetFunction() + ? buildAppConfig("with-flx").anonAuth().flexibleSync().triggerClientResetFunction() : buildAppConfig("with-pbs").anonAuth().partitionBasedSync().triggerClientResetFunction(), ); authenticateUserBefore(); From 6f42600f8ccd514154661cd580be73c169e0af5a Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Thu, 26 Oct 2023 15:33:42 +0200 Subject: [PATCH 03/16] Remove long timeout --- integration-tests/tests/src/tests/sync/client-reset.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-tests/tests/src/tests/sync/client-reset.ts b/integration-tests/tests/src/tests/sync/client-reset.ts index 1b5b430760..7995383a8f 100644 --- a/integration-tests/tests/src/tests/sync/client-reset.ts +++ b/integration-tests/tests/src/tests/sync/client-reset.ts @@ -469,7 +469,6 @@ function getSchema(useFlexibleSync: boolean) { it(`handles discard local simulated client reset with ${getPartialTestTitle( useFlexibleSync, )} sync enabled`, async function (this: RealmContext) { - this.timeout(120 * 1000); // (i) using a client reset in "DiscardUnsyncedChanges" mode, a fresh copy // of the Realm will be downloaded (resync) // (ii) two callback will be called, while the sync error handler is not From 5c0a0e5fa7d2a76a8d378d304f19a8716898d22d Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Fri, 27 Oct 2023 10:15:37 +0200 Subject: [PATCH 04/16] Longer timeout + retries --- integration-tests/tests/src/tests/sync/client-reset.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-tests/tests/src/tests/sync/client-reset.ts b/integration-tests/tests/src/tests/sync/client-reset.ts index 7995383a8f..5550b24605 100644 --- a/integration-tests/tests/src/tests/sync/client-reset.ts +++ b/integration-tests/tests/src/tests/sync/client-reset.ts @@ -544,7 +544,8 @@ function getSchema(useFlexibleSync: boolean) { // of the Realm will be downloaded (resync) // (ii) two callback will be called, while the sync error handler is not // (iii) after the reset, the Realm can be used as before - this.longTimeout(); + this.timeout(5 * 60 * 1000); + this.retries(3); const clientResetBefore = (realm: Realm) => { expect(realm.schema.length).to.equal(2); }; From 8067b07c907c6d577670c8d0c847cb92579adc4e Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Mon, 30 Oct 2023 16:48:54 +0100 Subject: [PATCH 05/16] Temporarily increasing the timeout of HTTP requests --- packages/realm-app-importer/src/AdminApiClient.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/realm-app-importer/src/AdminApiClient.ts b/packages/realm-app-importer/src/AdminApiClient.ts index cebf3f23dc..6280347f2c 100644 --- a/packages/realm-app-importer/src/AdminApiClient.ts +++ b/packages/realm-app-importer/src/AdminApiClient.ts @@ -386,6 +386,7 @@ export class AdminApiClient { // Setting additional options to signal to the RN fetch polyfill that it shouldn't consider the response a "blob" // see https://github.com/react-native-community/fetch/issues/15 reactNative: { textStreaming: true }, + timeoutMs: 5000, } as FetchRequestInit); if (response.ok) { if (response.headers.get("content-type") === "application/json") { From 040f189c8c421e085d287fddeb10e0e3efd5d481 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Tue, 31 Oct 2023 11:56:05 +0100 Subject: [PATCH 06/16] Revert "Temporarily increasing the timeout of HTTP requests" This reverts commit 8067b07c907c6d577670c8d0c847cb92579adc4e. --- packages/realm-app-importer/src/AdminApiClient.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/realm-app-importer/src/AdminApiClient.ts b/packages/realm-app-importer/src/AdminApiClient.ts index 6280347f2c..cebf3f23dc 100644 --- a/packages/realm-app-importer/src/AdminApiClient.ts +++ b/packages/realm-app-importer/src/AdminApiClient.ts @@ -386,7 +386,6 @@ export class AdminApiClient { // Setting additional options to signal to the RN fetch polyfill that it shouldn't consider the response a "blob" // see https://github.com/react-native-community/fetch/issues/15 reactNative: { textStreaming: true }, - timeoutMs: 5000, } as FetchRequestInit); if (response.ok) { if (response.headers.get("content-type") === "application/json") { From 6ba97a76fb081425e879fac64f80b7ca2f738e7f Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Tue, 31 Oct 2023 11:59:05 +0100 Subject: [PATCH 07/16] wip - debugging --- packages/realm-app-importer/src/AdminApiClient.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/realm-app-importer/src/AdminApiClient.ts b/packages/realm-app-importer/src/AdminApiClient.ts index cebf3f23dc..fb67e1a5e1 100644 --- a/packages/realm-app-importer/src/AdminApiClient.ts +++ b/packages/realm-app-importer/src/AdminApiClient.ts @@ -379,6 +379,7 @@ export class AdminApiClient { if (typeof body === "object") { headers["content-type"] = "application/json"; } + console.log("FISK 111", { ...rest, body: JSON.stringify(body), headers, reactNative: { textStreaming: true } }); const response = await DefaultNetworkTransport.fetch(url, { ...rest, body: JSON.stringify(body), From fc1d2462a4f976e4fce1ca811fe69365a03192a4 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Tue, 31 Oct 2023 13:07:15 +0100 Subject: [PATCH 08/16] Add eol --- packages/realm-app-importer/src/AdminApiClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/realm-app-importer/src/AdminApiClient.ts b/packages/realm-app-importer/src/AdminApiClient.ts index fb67e1a5e1..2d4dc94a5b 100644 --- a/packages/realm-app-importer/src/AdminApiClient.ts +++ b/packages/realm-app-importer/src/AdminApiClient.ts @@ -382,7 +382,7 @@ export class AdminApiClient { console.log("FISK 111", { ...rest, body: JSON.stringify(body), headers, reactNative: { textStreaming: true } }); const response = await DefaultNetworkTransport.fetch(url, { ...rest, - body: JSON.stringify(body), + body: JSON.stringify(body + "\n"), headers, // Setting additional options to signal to the RN fetch polyfill that it shouldn't consider the response a "blob" // see https://github.com/react-native-community/fetch/issues/15 From f1312add14df4249d6402abc9c350f2025466ca0 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Tue, 31 Oct 2023 13:31:58 +0100 Subject: [PATCH 09/16] Revert "Add eol" This reverts commit fc1d2462a4f976e4fce1ca811fe69365a03192a4. --- packages/realm-app-importer/src/AdminApiClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/realm-app-importer/src/AdminApiClient.ts b/packages/realm-app-importer/src/AdminApiClient.ts index 2d4dc94a5b..fb67e1a5e1 100644 --- a/packages/realm-app-importer/src/AdminApiClient.ts +++ b/packages/realm-app-importer/src/AdminApiClient.ts @@ -382,7 +382,7 @@ export class AdminApiClient { console.log("FISK 111", { ...rest, body: JSON.stringify(body), headers, reactNative: { textStreaming: true } }); const response = await DefaultNetworkTransport.fetch(url, { ...rest, - body: JSON.stringify(body + "\n"), + body: JSON.stringify(body), headers, // Setting additional options to signal to the RN fetch polyfill that it shouldn't consider the response a "blob" // see https://github.com/react-native-community/fetch/issues/15 From f0a9f329015922b5f923cd918942e6114eba3fa8 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Tue, 31 Oct 2023 13:39:38 +0100 Subject: [PATCH 10/16] debug: more logging --- .github/workflows/pr-realm-js.yml | 2 +- .github/workflows/test-server.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-realm-js.yml b/.github/workflows/pr-realm-js.yml index 69a33e6995..1a5eaf6e50 100644 --- a/.github/workflows/pr-realm-js.yml +++ b/.github/workflows/pr-realm-js.yml @@ -284,7 +284,7 @@ jobs: echo "url=https://${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Trigger the test server workflow to start the server - run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }} + run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }} -r ${{ github.ref_name }} env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/test-server.yml b/.github/workflows/test-server.yml index b2a3fac953..f311145b35 100644 --- a/.github/workflows/test-server.yml +++ b/.github/workflows/test-server.yml @@ -28,7 +28,7 @@ jobs: echo "subdomain=${subdomain}" >> $GITHUB_OUTPUT; echo "hostname=${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Start Ngrok - run: docker run --detach --network host --env NGROK_AUTHTOKEN ngrok/ngrok http --subdomain ${{ steps.ngrok-config.outputs.subdomain }} 9090 + run: docker run --detach --network host --env NGROK_AUTHTOKEN ngrok/ngrok http --log-level debug --log stderr --subdomain ${{ steps.ngrok-config.outputs.subdomain }} 9090 env: NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }} - name: Preparing server entrypoint From 79b073278ecb19a13111d29868541c5dce967427 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Tue, 31 Oct 2023 16:25:14 +0100 Subject: [PATCH 11/16] Try larger timeout --- .github/workflows/pr-realm-js.yml | 2 +- .github/workflows/test-server.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-realm-js.yml b/.github/workflows/pr-realm-js.yml index 1a5eaf6e50..a486d63d68 100644 --- a/.github/workflows/pr-realm-js.yml +++ b/.github/workflows/pr-realm-js.yml @@ -284,7 +284,7 @@ jobs: echo "url=https://${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Trigger the test server workflow to start the server - run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }} -r ${{ github.ref_name }} + run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }} -r kneth/client-reset env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/test-server.yml b/.github/workflows/test-server.yml index f311145b35..ed70ddb77a 100644 --- a/.github/workflows/test-server.yml +++ b/.github/workflows/test-server.yml @@ -28,7 +28,7 @@ jobs: echo "subdomain=${subdomain}" >> $GITHUB_OUTPUT; echo "hostname=${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Start Ngrok - run: docker run --detach --network host --env NGROK_AUTHTOKEN ngrok/ngrok http --log-level debug --log stderr --subdomain ${{ steps.ngrok-config.outputs.subdomain }} 9090 + run: docker run --detach --network host --env NGROK_AUTHTOKEN ngrok/ngrok --connect_timeout 60 http --subdomain ${{ steps.ngrok-config.outputs.subdomain }} 9090 env: NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }} - name: Preparing server entrypoint From 53b1fdfb4f78f1bd2512ae9d43071b877cb9e3ac Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Wed, 1 Nov 2023 09:22:09 +0100 Subject: [PATCH 12/16] Revert "Try larger timeout" This reverts commit 79b073278ecb19a13111d29868541c5dce967427. --- .github/workflows/pr-realm-js.yml | 2 +- .github/workflows/test-server.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-realm-js.yml b/.github/workflows/pr-realm-js.yml index a486d63d68..1a5eaf6e50 100644 --- a/.github/workflows/pr-realm-js.yml +++ b/.github/workflows/pr-realm-js.yml @@ -284,7 +284,7 @@ jobs: echo "url=https://${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Trigger the test server workflow to start the server - run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }} -r kneth/client-reset + run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }} -r ${{ github.ref_name }} env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/test-server.yml b/.github/workflows/test-server.yml index ed70ddb77a..f311145b35 100644 --- a/.github/workflows/test-server.yml +++ b/.github/workflows/test-server.yml @@ -28,7 +28,7 @@ jobs: echo "subdomain=${subdomain}" >> $GITHUB_OUTPUT; echo "hostname=${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Start Ngrok - run: docker run --detach --network host --env NGROK_AUTHTOKEN ngrok/ngrok --connect_timeout 60 http --subdomain ${{ steps.ngrok-config.outputs.subdomain }} 9090 + run: docker run --detach --network host --env NGROK_AUTHTOKEN ngrok/ngrok http --log-level debug --log stderr --subdomain ${{ steps.ngrok-config.outputs.subdomain }} 9090 env: NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }} - name: Preparing server entrypoint From fe0f086f88d22acafb7b9cd498d2c7e5286c8445 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Wed, 1 Nov 2023 11:34:06 +0100 Subject: [PATCH 13/16] wip --- .github/workflows/pr-realm-js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-realm-js.yml b/.github/workflows/pr-realm-js.yml index 1a5eaf6e50..0e240b0be3 100644 --- a/.github/workflows/pr-realm-js.yml +++ b/.github/workflows/pr-realm-js.yml @@ -284,7 +284,7 @@ jobs: echo "url=https://${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Trigger the test server workflow to start the server - run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }} -r ${{ github.ref_name }} + run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG } env: GH_TOKEN: ${{ github.token }} From 824bd840c590ea353edc49e5f4caa406fa042cfc Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Wed, 1 Nov 2023 12:39:10 +0100 Subject: [PATCH 14/16] wip --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2f8cc5e79..241bf0af44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,9 +16,6 @@ * File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms). ### Internal - - - * Some disabled tests for client reset (partition based sync) have been enabled. ([#6201](https://github.com/realm/realm-js/issues/6201) ## 12.2.1 (2023-10-05) From 7cb574f745f2021beca076dc14c17a76c73c7a58 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Wed, 1 Nov 2023 16:35:30 +0100 Subject: [PATCH 15/16] Disable server-side client reset due to ngrok issues --- integration-tests/tests/src/tests/sync/client-reset.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/integration-tests/tests/src/tests/sync/client-reset.ts b/integration-tests/tests/src/tests/sync/client-reset.ts index 5550b24605..ed191858e7 100644 --- a/integration-tests/tests/src/tests/sync/client-reset.ts +++ b/integration-tests/tests/src/tests/sync/client-reset.ts @@ -293,6 +293,8 @@ function getSchema(useFlexibleSync: boolean) { } // FIXME: testing flexible sync is currently disabled as it is timing out +// FIXME: ngrok reports "Syntax Error" when tiggerClientResetFunction() is used. +// Once ngrok behaves nicely, the skipped tests can be enabled. [false /*, true*/].forEach((useFlexibleSync) => { describe.skipIf( environment.missingServer, @@ -301,8 +303,8 @@ function getSchema(useFlexibleSync: boolean) { this.longTimeout(); // client reset with flexible sync can take quite some time importAppBefore( useFlexibleSync - ? buildAppConfig("with-flx").anonAuth().flexibleSync().triggerClientResetFunction() - : buildAppConfig("with-pbs").anonAuth().partitionBasedSync().triggerClientResetFunction(), + ? buildAppConfig("with-flx").anonAuth().flexibleSync() /* .triggerClientResetFunction() */ + : buildAppConfig("with-pbs").anonAuth().partitionBasedSync() /* .triggerClientResetFunction() */, ); authenticateUserBefore(); @@ -511,7 +513,7 @@ function getSchema(useFlexibleSync: boolean) { ); }); - it(`handles discard local client reset with ${getPartialTestTitle( + it.skip(`handles discard local client reset with ${getPartialTestTitle( useFlexibleSync, )} sync enabled`, async function (this: RealmContext) { // (i) using a client reset in "DiscardUnsyncedChanges" mode, a fresh copy @@ -537,7 +539,7 @@ function getSchema(useFlexibleSync: boolean) { ); }); - it(`handles recovery client reset with ${getPartialTestTitle( + it.skip(`handles recovery client reset with ${getPartialTestTitle( useFlexibleSync, )} sync enabled`, async function (this: RealmContext) { // (i) using a client reset in "Recovery" mode, a fresh copy From 87e8c5e23d1a57c92f2698dfa4b43d397c04dd9e Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Thu, 2 Nov 2023 08:28:39 +0100 Subject: [PATCH 16/16] revert --- .github/workflows/pr-realm-js.yml | 2 +- .github/workflows/test-server.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-realm-js.yml b/.github/workflows/pr-realm-js.yml index 0e240b0be3..69a33e6995 100644 --- a/.github/workflows/pr-realm-js.yml +++ b/.github/workflows/pr-realm-js.yml @@ -284,7 +284,7 @@ jobs: echo "url=https://${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Trigger the test server workflow to start the server - run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG } + run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }} env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/test-server.yml b/.github/workflows/test-server.yml index f311145b35..b2a3fac953 100644 --- a/.github/workflows/test-server.yml +++ b/.github/workflows/test-server.yml @@ -28,7 +28,7 @@ jobs: echo "subdomain=${subdomain}" >> $GITHUB_OUTPUT; echo "hostname=${subdomain}.ngrok.io" >> $GITHUB_OUTPUT; - name: Start Ngrok - run: docker run --detach --network host --env NGROK_AUTHTOKEN ngrok/ngrok http --log-level debug --log stderr --subdomain ${{ steps.ngrok-config.outputs.subdomain }} 9090 + run: docker run --detach --network host --env NGROK_AUTHTOKEN ngrok/ngrok http --subdomain ${{ steps.ngrok-config.outputs.subdomain }} 9090 env: NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }} - name: Preparing server entrypoint