sillsdev / sillsdev/languageforge-lexbox

First lexbox requests hitting vite proxy fail after local deployment

Open
#313 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Svelte 🧑‍💻 DX
Dominant language
C#
Stars
9
Forks
8
Avg merge
2d 13h
Merged PRs (30d)
49

Description

The first request that hits the lexbox deployment (lexbox-api & otel-collector) via the vite proxy always seems to fail.
(I can't trigger the error if I run task up and access the app at localhost.)

To reproduce

  1. Start the cluster without the ui (if it's not already running)
  • e.g. task backend-up
  1. Kill the containers:
  • k8s_POD_lexbox-***...
  • k8s_lexbox-api_lexbox-***... (you don't have to kill this one, but it causes everything to restart faster)
  1. Wait for the successful health check log
  • (e.g.) Request finished HTTP/1.1 GET http://10.1.1.98:5158/api/healthz - - - 200 - text/plain 57.5309ms
  1. Try one of the following scenarios
1. 1st & 2nd requests hit proxy = 💥 & 🟢
  1. Invoke-WebRequest -Uri "http://localhost:3000/api/login"
    💥 ===> The remote server returned an error: (500) Internal Server Error.
Error: socket hang up
    at connResetException (node:internal/errors:704:14)
    at Socket.socketOnEnd (node:_http_client:505:23)
    at Socket.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ECONNRESET'
}
  1. Invoke-WebRequest -Uri "http://localhost:3000/api/login"
    🟢 ===> The remote server returned an error: (401) Unauthorized.
1. 1st request hits ingress & 2nd request hits proxy = 🟢 & 🟢
  1. Invoke-WebRequest -Uri "http://localhost:5158/api/login"
    🟢 ===> The remote server returned an error: (401) Unauthorized.

  2. Invoke-WebRequest -Uri "http://localhost:3000/api/login"
    🟢 ===> The remote server returned an error: (401) Unauthorized.

Debugging

You can hook into the proxy client's events for further debugging. E.g.:

      '/api': {
        target: 'http://localhost:5158',
        toProxy: true,
        timeout: 1200000,
        proxyTimeout: 1200000,
        followRedirects: true,
        configure: (proxy, _options) => {
          proxy.on('error', (err, _req, _res, target) => {
            console.log('PROXY - api - error', err, _req.headers.host, target);
          });
          proxy.on('proxyReq', (proxyReq, req, _res) => {
            console.log('Proxy request', proxyReq);
            console.log('PROXY - api - request:', req.method, req.headers.host, req.url);
          });
          proxy.on('proxyRes', (proxyRes, req, _res) => {
            console.log('PROXY - api - response:', proxyRes.statusCode, req.headers.host, req.url);
          });
        },
      },

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Vite proxy configuration shown in the issue and reproduce the failure using task backend-up, the container restarts, and the /api/login requests on ports 3000 and 5158. Use the proxy client event hooks described in the issue to compare the first proxied request with the direct ingress request. Done means the first request through the Vite proxy no longer returns a 500/socket hang up and instead behaves like the direct request.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, vite
Domain
devops, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.