fastify/fastify-http-proxy

TrailerMismatchError when following the instruction from readme.md

woss opened this issue · 2 comments

woss commented

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.28.0

Plugin version

6.2.2

Node.js version

16.14.2

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

debian 11

Description

after following the installation and setup from the readme.md i get this error

[1650708990255] WARN (20425 on 589db73f9ca3): response terminated with an error with headers already sent
    reqId: "req-1"
    err: {
      "type": "TrailerMismatchError",
      "message": "Trailers does not match trailer header",
      "stack":
          TrailerMismatchError: Trailers does not match trailer header
              at Parser.onMessageComplete (/workspace/common/temp/node_modules/.pnpm/undici@4.16.0/node_modules/undici/lib/client.js:957:30)
              at wasm_on_message_complete (/workspace/common/temp/node_modules/.pnpm/undici@4.16.0/node_modules/undici/lib/client.js:468:30)
              at wasm://wasm/0002afd2:wasm-function[45]:0x8dc
              at wasm://wasm/0002afd2:wasm-function[56]:0x1ad3
              at wasm://wasm/0002afd2:wasm-function[55]:0xcd7
              at wasm://wasm/0002afd2:wasm-function[21]:0x4e4
              at Parser.execute (/workspace/common/temp/node_modules/.pnpm/undici@4.16.0/node_modules/undici/lib/client.js:602:22)
              at Parser.readMore (/workspace/common/temp/node_modules/.pnpm/undici@4.16.0/node_modules/undici/lib/client.js:570:12)
              at Socket.onSocketReadable (/workspace/common/temp/node_modules/.pnpm/undici@4.16.0/node_modules/undici/lib/client.js:1019:10)
              at Socket.emit (node:events:526:28)
      "name": "TrailerMismatchError",
      "code": "UND_ERR_TRAILER_MISMATCH"
    }

I searched for the solutions and only thing i can find is this nodejs/undici#880 which was not useful at all.

Steps to Reproduce

follow the readme.md

Expected Behavior

to work

Eomm commented

Could you add a Minimal, Reproducible Example?

Without it, we are unable to help you (and follow the readme.md is not a runnable example).

woss commented

Could you add a Minimal, Reproducible Example?

Hmm, I'm not going to make the repo so i can with all the standard TS setup.

Without it, we are unable to help you (and follow the readme.md is not a runnable example).

Why not? So the example code should be taken as here is the example, not sure will it work?.


This below is not that different from the https://github.com/fastify/fastify-http-proxy#example which should be considered as a working example. The code below it's a standard TS with standard tsconfig.json.

package.json

{
    "fastify": "~3.28.0",
    "fastify-http-proxy": "~6.2.2",
    "fastify-plugin": "~3.0.1",
}

The start.ts file.

import Fastify, { FastifyInstance } from 'fastify';
import fastifyHttpProxy from 'fastify-http-proxy';

const ipfsServer: string = 'http://127.0.0.1:5001';

/**
 * Main entry point
 * @public
 */
export async function main(): Promise<void> {
  const server: FastifyInstance = Fastify({
    logger: {
      prettyPrint: true
    }
  });

  server.register(fastifyHttpProxy, {
    upstream: ipfsServer,
    prefix: '/',
    http2: false
  });

  await server.listen(3000, '0.0.0.0');

  process.on('SIGTERM', () => {
    console.log('got SIGTERM');

    server.close(() => {
      console.log('Process terminated');
    });
  });
}

main().catch(console.error);

And for your convenience here is the screenshot too:
image

The reason why i posted this here and not in the undici is because the same people are involved and posting it there would require me to make the repo and setup to demo the error, while here is literally the example from the readme.md