Skip to content

Unicode emoji converted to broken chars in certain extreme long string responses #288

@stanleyxu2005

Description

@stanleyxu2005

Prerequisites

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

Fastify version

4.26.2

Plugin version

7.0.2

Node.js version

18.x

Operating system

Windows

Description

Download a 200kb yaml plain text file with fastify/compress. Certain lines of the yaml contains illegal chars.

image

As you can see, on the left side (without compress), icons in the small green box are same.
But on the right side, one of the icon becomes 2 strange question marks.

The content encoding is br (I tried with gzip, same error)

image

Any thoughts, what can be the root cause?

Steps to Reproduce

const fastify = new Fastify({})
fastify.register(fastifyCompress)

fastify.get('/subscription', async (req, reply) => {
  const subscription = await handler.downloadClashSubscriptionAsync(config)

  // await require('fs').promises
  //   .writeFile('/out.txt', subscription, 'utf-8')  // <--- the file content is okay

  return reply.send(subscription)  // <--- the file content is corrupt
})

Expected Behavior

Dont expect the two question marks appear in the content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions