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

Conversation

kapis
Copy link

@kapis kapis commented Sep 9, 2025

This fixes a bug that happens when the session_bytes become too long due to large state declared.

Before the fix, a long session_bytes would cause OSError: [Errno 7] Argument list too long: 'deno' as the length of command becomes too long (see added test cases).

The fix is to use stdin to pipe the bytes from Python to Deno.

@kapis kapis force-pushed the main branch 2 times, most recently from cc9730c to 6de5cfc Compare September 10, 2025 14:58
fix

remove non-std options

add stdin processing of all

fixik

Revert "fix tests"

This reverts commit 6de5cfc.
@kapis
Copy link
Author

kapis commented Oct 8, 2025

@christian-bromann @eyurtsev @vbarda @hntrl
Sorry to bother, any chance this will be reviewed?

Also, what's the current status of this repo? Is it maintained at all? As I see, the deps weren't updated for the long time

@eyurtsev
Copy link
Collaborator

eyurtsev commented Oct 8, 2025

Not actively maintaining ATM. Might change in the future. Feel free to fork and release your own version

@eyurtsev eyurtsev requested a review from Copilot October 8, 2025 13:55
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where execution fails when session_bytes becomes too long, causing an "Argument list too long" error when passed as command-line arguments. The fix changes the approach from passing session bytes as CLI arguments to piping them through stdin.

Key changes:

  • Modified command building to use --session-stdin flag instead of passing bytes as arguments
  • Updated process execution to pipe session bytes through stdin
  • Added support for reading session bytes from stdin in the Deno TypeScript code

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
libs/sandbox-py/tests/unit_tests/test_pyodide_sandbox.py Added comprehensive test cases for both async and sync execution with large session bytes
libs/sandbox-py/langchain_sandbox/pyodide.py Modified command building and process execution to use stdin piping instead of CLI arguments
libs/pyodide-sandbox-js/main.ts Added stdin reading support and updated session bytes handling to accept both string and binary formats

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

code_create = "big = 'x' * (2 * 1024 * 1024); print(len(big))"
first = await sandbox.execute(code_create)
assert first.status == "success", f"Encountered error: {first.stderr}"
assert first.stdout == str(2 * 1024 * 1024)
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 2 * 1024 * 1024 is repeated multiple times. Consider extracting this to a constant like LARGE_SESSION_SIZE = 2 * 1024 * 1024 to improve maintainability and make the test intention clearer.

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
code_create = "big = 'x' * (2 * 1024 * 1024); print(len(big))"
first = sandbox.execute(code_create)
assert first.status == "success", f"Encountered error: {first.stderr}"
assert first.stdout == str(2 * 1024 * 1024)
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 2 * 1024 * 1024 is repeated multiple times. Consider extracting this to a constant like LARGE_SESSION_SIZE = 2 * 1024 * 1024 to improve maintainability and make the test intention clearer.

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
if (flags["session-stdin"]) {
const chunks: Uint8Array[] = [];
for await (const chunk of Deno.stdin.readable) {
chunks.push(chunk as Uint8Array);
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type assertion as Uint8Array could potentially fail if the chunk is not actually a Uint8Array. Consider using a type guard or validation to ensure type safety.

Suggested change
chunks.push(chunk as Uint8Array);
if (!(chunk instanceof Uint8Array)) {
throw new TypeError("Expected chunk to be a Uint8Array from Deno.stdin.readable");
}
chunks.push(chunk);

Copilot uses AI. Check for mistakes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

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