You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When executing a command using the E2B sandbox code interpreter (even a simple command like ls -l), the SDK returns a streaming response. However, any attempt to print or otherwise access the result (for example, with print(result)) triggers a RuntimeError with the message:
"Attempted to access 'response.content' on a streaming response. Call 'response.read()' first."
Even after trying to explicitly read the stream (using await result.aread() in an async context or result.read() in a synchronous context), the error persists because the package appears to attempt to access the response content before the stream has been fully buffered (atleast, that's what I guess is going on.)
To Reproduce
Steps to reproduce the behavior:
Initialize an E2B sandbox.
Run a simple command. For example: result = sandbox.commands.run('ls -l') print(result)
A RuntimeError will raise with the message about accessing response.content on a streaming response.
Expected behavior
The command should be executed properly, and after it completes, accessing the result (or printing it) should not trigger an error.
Browser console output
N/A (This is a Python package issue, not a browser issue.)
which produces the same error. Even when attempting to call await result.aread() before accessing the result, the error is raised internally within the package. This behavior prevents any downstream access to the full command output, making it impossible to execute any command in the sandbox.
The text was updated successfully, but these errors were encountered:
I just tried to use the GPT 4o model to generate an SVG file and list and watch the directory to download that later. Even running the simple commands after initiating the sandbox and manually connecting to it, results in that specified error.
Now, I have tried and used the run_code method to bypass this: result = sandbox.run_code(f'ls -l {remote_dir}', 'bash')
Only this works. Also, any attempt to read and save an image file will result in an error unless we specify 'bytes' param along with it.
Something like this:
remote_file = "/home/user/test.svg"
local_filename = "test.svg"
content = sandbox.files.read(remote_file, 'bytes')
with open(local_filename, "wb") as f:
f.write(content)
print(f"Downloaded new SVG.")
Describe the bug
When executing a command using the E2B sandbox code interpreter (even a simple command like
ls -l
), the SDK returns a streaming response. However, any attempt to print or otherwise access the result (for example, withprint(result)
) triggers a RuntimeError with the message:Even after trying to explicitly read the stream (using
await result.aread()
in an async context orresult.read()
in a synchronous context), the error persists because the package appears to attempt to access the response content before the stream has been fully buffered (atleast, that's what I guess is going on.)To Reproduce
Steps to reproduce the behavior:
result = sandbox.commands.run('ls -l') print(result)
response.content
on a streaming response.Expected behavior
The command should be executed properly, and after it completes, accessing the result (or printing it) should not trigger an error.
Browser console output
N/A (This is a Python package issue, not a browser issue.)
Terminal commands & output
Terminal command executed:
result = sandbox.commands.run('ls -l', on_stdout=lambda data: print(data)) print(result)
Terminal output:
Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):
N/A
Additional context
I also tried the example command from the documentation:
which produces the same error. Even when attempting to call
await result.aread()
before accessing the result, the error is raised internally within the package. This behavior prevents any downstream access to the full command output, making it impossible to execute any command in the sandbox.The text was updated successfully, but these errors were encountered: