-
Notifications
You must be signed in to change notification settings - Fork 22
Description
**Description: **
Currently, the CodeSandbox.sandboxes.list() method is designed to retrieve and filter the full list of sandboxes for an organization. While this works adequately for teams with a manageable number of sandboxes (e.g., 500–1000), it becomes inefficient and costly when scaled to larger organizations with thousands (e.g., 5000+) of sandboxes.
The current workaround involves listing all sandboxes and filtering them manually, as shown below:
export function getSandbox(sandboxId: string) {
return new Promise(async (resolve, reject) => {
try {
const sandboxes = await csb.sandboxes.list();
const sandbox = sandboxes.sandboxes.find((sb) => sb.id === sandboxId);
resolve({
success: true,
sandbox: sandbox
});
} catch (error) {
console.error("Error getting sandbox:", error);
reject(error);
}
});
}
This pattern becomes even more problematic when attempting to retrieve metadata for multiple sandboxes. Iterating through multiple pages of results to find a small subset of relevant IDs adds significant latency and unnecessary load, especially when dealing with paginated APIs and large datasets.
**Use Case: **
We often need to retrieve metadata for a known list of sandbox IDs—sometimes dozens or hundreds at a time—without resuming or fully hydrating them. The current list-and-filter approach:
Requires loading potentially thousands of sandboxes.
Involves inefficient pagination traversal.
Introduces latency that compounds with each request.
**Expected Behavior: **
We would like a more scalable and efficient SDK method that allows:
Direct retrieval of metadata for one or more known sandbox IDs (e.g., ["id1", "id2", "id3"]).
Optional ability to bypass hydration/resume.
Avoidance of full list operations when not necessary.
- This Issue is Feedback from our Developers at LegionEdge (Including Myself)
If there is an alternative approach or GET Request URL that allows the retrieval of this information let me know!