Skip to content

[Bug]: list reporter corrupts test stdout/stderr that is not valid UTF-8 per chunk (multi-byte chars split across writes) #43079

Closed

Description

Version

main @ 48688e0 (1.64.0-next); the code paths are unchanged in 1.63

Steps to reproduce

import { test } from '@playwright/test';

test('split multi-byte char', async () => {
  // "€\n" = e2 82 ac 0a, written in two chunks
  process.stdout.write(Buffer.from([0xe2, 0x82]));
  process.stdout.write(Buffer.from([0xac, 0x0a]));
});

Run with npx playwright test --reporter=list.

Expected behavior

The terminal shows €, as it did before #42886, because the reporter wrote the raw bytes through to the stream.

Actual behavior

The terminal shows �� (two replacement characters). This happens with or without printWorkerIndex.

Since #42886 (printWorkerIndex), ListReporter._dumpToStdio does chunk.toString('utf-8') and writes the decoded string instead of chunk. Worker output reaches the reporter as Buffers (stdioChunkToParams sends Uint8Array chunks as base64), so each chunk is decoded on its own. A character split across two writes is lost, and so is any output that isn't UTF-8, such as Latin-1 from a child process. Decoding the two chunks separately gives "��\n", while the concatenated bytes give "€\n".

Additional context

Suggested fix: when there is no worker prefix to add, write the original chunk unchanged. When prefixing, decode with a per-stream StringDecoder (node:string_decoder) so partial sequences carry over to the next chunk. Low severity; found during a code review.

Environment

Not environment-specific: the code is platform-independent.
Verified by running the functions from packages/playwright-core/src/server (or the reporter logic) directly with Node 22.22 on Linux x64.
No browser is needed to reproduce.

Activity

  1. dgozman commented on Oct 6, 2026

    @dgozman
    Collaborator

    Fixed by #43149.

  2. CloneOfAlex commented on Oct 6, 2026

    @CloneOfAlex
    Author

    nicely done - thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions