Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Emscripten: Improve standard stream handling in node_entry.mjs #146416

Copy link
Copy link
@hoodmane

Description

@hoodmane
Issue body actions

The standard streams that Emscripten provides out of the box have the following deficiencies:

  1. The emscripten std streams always have isatty set to true, whereas they should reflect isatty for the node std streams.
  2. The emscripten std streams don't support the ttygetwinsize ioctl so shutil.get_terminal_size() doesn't work.
  3. The emscripten std streams introduce an extra layer of buffering which has
    to be flushed with fsync().
  4. The emscripten std streams are slow and complex because they go through a
    character-based handler layer. This is particularly awkward because both
    sides of this character based layer deal with buffers and so we need
    complex adaptors, buffering, etc on both sides. Removing this
    character-based middle layer makes everything better.
    https://github.com/emscripten-core/emscripten/blob/1aa7fb531f11e11e7ae49b75a24e1a8fe6fa4a7d/src/lib/libtty.js?plain=1#L104-L114

These issues are fixed in Pyodide in this file:
https://github.com/pyodide/pyodide/blob/main/src/js/streams.ts
We can fix it with an adapted version of that file.

Inspired by the discussion of terminal coloring here:
python/buildmaster-config#687 (comment)
The Emscripten build bot was coloring the output but other build bots don't. The reason was tracked down to the incorrect behavior of isatty because if isatty(stdout) is false, unittest will automatically disable terminal coloring. So this will fix the build bot.

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.