Add fault-proxy: single-file GraphQL fault-injection proxy#4
Open
ria8651 wants to merge 1 commit into
Open
Conversation
A single-file Node reverse proxy that sits between the omSupply client and server and injects error/connectivity states that are hard to reproduce by hand: socket drop (NetworkError + connection banner), HTTP 500 no body, typed GraphQL errors (Unauthenticated / Forbidden / Bad user input / Internal error), errors-plus-partial-data, and a configurable response delay. Built to exercise the typed-error + connection-banner work in open-msupply PR #11444 (and the #11885 long-delay work). Streams in passthrough mode, falls back to dropping the socket if the real upstream is down, and ships a live control panel at /__proxy plus a curl-friendly query/JSON API. No dependencies; Node 18+. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A tiny, zero-dependency Node reverse proxy for manual testing of the typed
GraphQL error + connection-lost banner work in open-msupply
PR #11444
(and the #11885 long-delay work).
It sits between the client and the real omSupply server, streams traffic
through unchanged, and lets you flip failure modes live from a control panel
(
/__proxy) or over curl — without touching the server.Modes
passofflineNetworkError→ ConnectionLostBanner / Pagehttp500NetworkError(transport-failure HTTP branch)internal/unauthenticated/forbidden/badinput{errors:[…]}partialerrors[]onto itdelaydelayMsKnobs:
scope(graphql-only / all),count(fault next N then auto-revert),delayMs,detail. All settable from the panel or as query params.Why it exists / relationship to #2
This is a deliberately separate, single-file take alongside James's
#2. They converged
on the same architecture independently; the strengths are complementary:
first-class
delaymode, a uniquepartial(errors + data) mode, andhonest upstream-down behaviour (drops the socket rather than returning a
proxy 502).
pathtargeting and curated presets that hitthe
QueryErrorHandlersilent-permission-path and long-detail-toast edgecases, plus
truncateand a mitmproxy variant.Opening both so we can pick one — or fold the per-operation/per-path targeting
from #2 onto this engine.
Test steps
Manual-test helper, no automated tests.
:8000(cd server && cargo run).node fault-proxy/fault-proxy.js(proxy:8001→:8000).cd client && yarn start --env API_HOST=http://localhost:8001.reacts (banner on
offline, re-login onunauthenticated, toast oninternal, etc.).Notes
data-plane port. Localhost-only.
read them with
credentials: 'include'.🤖 Generated with Claude Code