Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling tunnel errors as network failure #3697

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/loot-core/src/server/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ 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 headerKeys = res.headers.keys().toArray();
const tunnelError = tunnelErrorHeaders.some(tunnelErrorHeader =>
headerKeys.includes(tunnelErrorHeader),
);
MikesGlitch marked this conversation as resolved.
Show resolved Hide resolved

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);
}
}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3697.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [MikesGlitch]
---

Supporting the use of an ngrok tunnel when used to tunnel into actual-sync server