Skip to content

Custom templates seems ignored when creating sandbox from template #107

@marcospassos

Description

@marcospassos

Hi there, I've been trying to use the SDK for the past three days but haven't had any success.

It looks like the template I created is simply being ignored when I create a new sandbox. My project requires Node.js 22+, so I followed the documentation to define a minimal template:

.codesandbox/template.json

{
  "title": "Node.js",
  "description": "Custom Node.js template.",
  "tags": ["node", "javascript", "croct"],
  "published": false
}

.codesandbox/tasks.json

{
  "setupTasks": [
    "npm install",
    "npm install croct@latest -g"
  ]
}

.devcontainer/devcontainer.json

{
  "name": "Node.js",
  "image": "mcr.microsoft.com/devcontainers/javascript-node:22",
  "features": {
    "ghcr.io/devcontainers/features/python:1": {}
  }
}

I then published the template using:

npx @codesandbox/sdk build template

And created the sandbox like this:

const sandbox = await sdk.sandboxes.create({
  source: 'template',
  id: '<id>',
  privacy: 'unlisted',
});

Everything runs without errors, but the Node version inside the shell still returns v20:

const command = await session.commands.run("node -v");

Also, it seems like the npm install task hasn't been run either.

What am I missing here?

Beside this, most of my attempts failed due to unexpected errors when publishing template, which is out of my control and quickly consumed my usage quota.

Example:

[cluster: fc-us-1, sandboxId: wsylfs]: Restarting sandbox...
[cluster: fc-eu-0, sandboxId: tgxs3d]: Snapshot created
[cluster: fc-us-3, sandboxId: qfrwtx]: Setup step failed: Starting containers
Error: Setup step failed: Starting containers
    at node_modules/@codesandbox/sdk/dist/bin/codesandbox.cjs:53273:23
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Promise.all (index 2)
    at async Object.handler (node_modules/@codesandbox/sdk/dist/bin/codesandbox.cjs:53194:26)

This forced me to wait hours before trying again, even after emailing to request a limit increase so I could evaluate whether it fits our use case.

Is there any specific email I should use to get support for quota issues?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions