Skip to content

zph/dax-issue-300-repro

Repository files navigation

Dax Issue #300 Reproduction

This directory contains minimal reproduction cases for dax issue #300: "Execution error that may be due to missing tty or streams for Multiple layers of Dax+Jupyter Notebooks"

The Problem

When dax is used to execute a process (like Jupyter) that runs code containing dax commands, the nested dax execution fails with:

Error: Exited with code: 128
    at CommandChild.pipedStdoutBuffer

Root Cause

Dax defaults to using "inherit" for stdout/stderr streams. In nested execution contexts (especially non-interactive environments like Jupyter notebooks), stdio inheritance fails because the parent process's streams aren't properly available or configured.

Key locations in dax source:

  • Default stdio config: src/command.ts:138-143
  • Error thrown: src/command.ts:783
  • Stdio mapping: src/commands/executable.ts:126-134

Reproduction Scripts

1. Minimal Reproduction (No Jupyter Required)

The simplest way to test nested dax execution:

deno run --allow-all minimal_repro.ts

This script:

  • Creates an inner script that uses dax
  • Attempts to run it using outer dax with different stdio configurations
  • Tests failure scenarios with default stdio inheritance
  • Shows it works with explicit piped stdio

Note: This minimal reproduction actually succeeds in all scenarios when run in a normal terminal environment. The issue appears to be specific to Jupyter's non-interactive environment where stdio streams are handled differently.

2. Jupyter Notebook Reproduction (Requires Jupyter)

Full reproduction matching the original issue report:

Setup:

# Install Jupyter
pip install jupyter

# Install Deno Jupyter kernel
deno jupyter --install

Run:

# Execute the test harness
deno run --allow-all run_notebook.ts

This demonstrates the full nested scenario:

  1. Outer dax (in run_notebook.ts)
  2. Executes Jupyter nbconvert
  3. Which runs notebook_with_dax.ipynb
  4. Which contains dax commands (inner dax)

3. Simple Dax Command

A basic script using dax that works fine on its own:

deno run --allow-all simple_dax_command.ts

This succeeds because there's no nested execution.

Expected vs Actual Behavior

Expected

All scenarios should execute successfully, with dax commands working in any context.

Actual

  • ✓ Simple dax command works
  • ✗ Nested dax execution fails with exit code 128
  • ✓ Using explicit .stdout("piped").stderr("piped") works
  • ✓ Using native Deno.Command instead of dax works

Workaround

Until this is fixed, you can work around the issue by explicitly piping stdio:

// Instead of:
await $`command`;

// Use:
await $`command`.stdout("piped").stderr("piped");

Proposed Fix

The issue can be fixed by detecting non-interactive/Jupyter environments and automatically using piped stdio instead of inherited stdio. See analysis in the issue comments for detailed implementation options.

Files

  • minimal_repro.ts - Simplest reproduction without Jupyter
  • run_notebook.ts - Full Jupyter notebook execution scenario
  • notebook_with_dax.ipynb - Jupyter notebook using dax
  • simple_dax_command.ts - Basic dax script (works fine)
  • README.md - This file

Testing the Fix

Once a fix is implemented, run all reproduction scripts to verify:

  1. Nested dax execution works in all scenarios
  2. Default behavior unchanged for normal (non-nested) execution
  3. Jupyter notebook execution succeeds
  4. No regressions in existing functionality

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published