Workers SDK Issue Reports

← Back to Dashboard

#7103 🐛 BUG: When using a long string (more than 1192 chars) the output is broken into several chunks splitted by new lines

Recommendation:KEEP OPEN
Difficulty:n/a
Reasoning:

Valid bug caused by miniflare's readline-based stdout handling. Root cause documented in #4357. Affects DB queries (Neon), not just console output. No fix merged.

Suggested Action:

Link to #4357; prioritize fix due to real-world application impact

Analysis Report

Issue Review: cloudflare/workers-sdk#7103

Summary

Long strings (>1192 chars) in console.log output are broken into multiple lines due to miniflare's readline-based stdout handling.

Findings

  • Created: 2024-10-25
  • Updated: 2026-01-12
  • Version: wrangler 3.60.3 → 4.60.0 (major version upgrade since report)
  • Component: wrangler / miniflare
  • Labels: bug
  • Comments: 2 (maintainer response + reporter follow-up)

Key Evidence

  1. Root Cause Identified: The issue is in miniflare's pipeOutput function at packages/miniflare/src/runtime/index.ts. It uses rl.createInterface(stdout).on("line", ...) which splits output by newlines in the buffer - not actual newlines in the content:

    rl.createInterface(stdout).on("line", (data) => console.log(data));
    
  2. Known Issue: This exact problem is documented in issue #4357 "[Miniflare 3] Problems with the new logs" opened 2023-10-30 by Shopify (for Hydrogen CLI). That issue explicitly identifies:

    • Each string line is logged in its own console.log call
    • The readline module pipes logs line-by-line based on buffer boundaries, not content
    • Suggested fix: use .on("data") instead of readline
  3. Reporter Confirmed Real-World Impact: The reporter confirmed this causes actual failures when sending long database queries (Neon DB) - the query breaks due to unexpected line breaks being inserted.

  4. No Fix Found:

    • No PR explicitly fixes issue #7103
    • Issue #4357 (the parent issue describing this architectural problem) remains open
    • Changelog does not mention this fix
  5. Not Fixed in Current Version: The miniflare runtime source still uses the readline approach as of the latest codebase.

Recommendation

Status: KEEP OPEN

Reasoning: This is a valid, confirmed bug with real-world impact. The root cause has been identified and is documented in related issue #4357. The reporter confirmed this affects database queries (Neon DB), not just console output display. The underlying issue in miniflare's pipeOutput function has not been addressed.

Action:

  1. Link this issue to #4357 as a duplicate or related issue
  2. Consider prioritizing a fix since it affects actual application behavior (database queries), not just logging aesthetics
  3. Potential fix: Replace readline-based approach with data event handling, or implement proper buffering

Suggested Comment

This issue is related to #4357 which documents the architectural problem in miniflare's log handling. The pipeOutput function uses rl.createInterface().on("line") which splits output based on buffer boundaries rather than actual newlines in the content.

Since this affects actual application behavior (breaking database queries as you mentioned with Neon DB), not just console output display, we're keeping this open. Linking to #4357 for tracking the underlying fix.

Notes & Feedback (0)

No notes yet.

Add Note