-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Description
When attempting to execute a command within a Worker sandbox environment, the request fails with a TypeError: Invalid URL. This suggests that the base URL might not be set or doesn't correctly resolve within the Worker's environment, resulting in an undefined.
Steps to Reproduce
-
Configure a Worker project with a service binding for a sandbox service in
wrangler.toml. -
Enable the
nodejs_compatcompatibility flag. -
In the Worker's source code, retrieve the service binding for the sandbox.
-
Attempt to execute a command using the sandbox service like so:
// Assuming 'env.Sandbox' is the service binding for the sandbox service. const sandbox = getSandbox(env.Sandbox, "sandbox-test"); const result = await sandbox.exec("ls", []); console.log("result", result);
-
Run the Worker using
wrangler dev.
Expected Behavior
The sandbox.exec() method should successfully make an HTTP POST request to the configured sandbox service endpoint (e.g., http://127.0.0.1:8787/api/execute/) and return the result of the executed command.
Actual Behavior
The request fails, and the following error is thrown in the console:
[HTTP Client] Making POST request to undefined/api/execute/
✘ [ERROR] [HTTP Client] Request error: POST undefined/api/execute [TypeError: Invalid URL: undefined/api/execute]
Environment
- Wrangler version: 4.22.0
- Node.js version: v20.18.1
- Operating System: Linux
- Compatibility Date: 2024-05-01
- Enabled Compatibility Flags:
nodejs_compat,enable_request_signal
```log
[HTTP Client] Making POST request to undefined/api/execute/
✘ [ERROR] [HTTP Client] Request error: POST undefined/api/execute [TypeError: Invalid URL: undefined/api/execute]