diff --git a/packages/loot-core/src/server/post.ts b/packages/loot-core/src/server/post.ts index 8b49c359d41..1fa28cd22a0 100644 --- a/packages/loot-core/src/server/post.ts +++ b/packages/loot-core/src/server/post.ts @@ -15,6 +15,19 @@ function throwIfNot200(res, text) { const json = JSON.parse(text); throw new PostError(json.reason); } + + // Actual Sync Server may be exposed via a tunnel (e.g. ngrok). Tunnel errors should be treated as network errors. + const tunnelErrorHeaders = ['ngrok-error-code']; + const tunnelError = tunnelErrorHeaders.some(header => + res.headers.has(header), + ); + + if (tunnelError) { + // Tunnel errors are present when the tunnel is active and the server is not reachable e.g. server is offline + // When we experience a tunnel error we treat it as a network failure + throw new PostError('network-failure'); + } + throw new PostError(text); } } diff --git a/upcoming-release-notes/3697.md b/upcoming-release-notes/3697.md new file mode 100644 index 00000000000..7db7e739fcf --- /dev/null +++ b/upcoming-release-notes/3697.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [MikesGlitch] +--- + +Supporting the use of an ngrok tunnel when used to tunnel into actual-sync server