Skip to content

Python Runner: StringIO replacement of sys.stderr breaks libraries that call fileno() (e.g., Prisma, database drivers) #21304

@spaethtech

Description

@spaethtech

Bug Description

The Python task runner replaces sys.stderr with io.StringIO() to capture error output. However, StringIO does not implement a working fileno() method, which causes failures when executing code that uses external libraries (like Prisma, psycopg2, or other database drivers) that attempt to call sys.stderr.fileno().

Environment

  • n8n Version: 1.117.3
  • Deployment: Self-hosted (Docker with Native Python Runners)
  • Python Runner: External task runner mode (n8nio/runners:1.117.3)

To Reproduce

  1. Enable Native Python Runners with external task runner
  2. Install Prisma Python client in the runner container:
    pip install prisma
  3. Run this code in an n8n Python Code node:
    from prisma import Prisma
    
    db = Prisma()
    db.connect()
    settings = db.setting.find_many()
    db.disconnect()
    
    return {'count': len(settings)}

Expected behavior

The code should execute successfully and return results from the database query.

Debug Info

Debug info

core

  • n8nVersion: 1.117.3
  • platform: docker (self-hosted)
  • nodeJsVersion: 22.18.0
  • nodeEnv: production
  • database: postgres
  • executionMode: regular
  • concurrency: -1
  • license: enterprise (production)
  • consumerId: 7527b28f-d26b-4db7-8d5b-2dc34312a99a

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: memory

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/141.0.0.0 safari/537.36
  • isTouchDevice: false

Generated at: 2025-10-29T06:02:07.808Z

Operating System

Docker

n8n Version

1.117.3

Node.js Version

22.18.0

Database

PostgreSQL

Execution mode

main (default)

Hosting

self hosted

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