edge.save.limit()

The save.limit() method of the edge object deploys the current playground to every route in Code.D. With path: '/del' it deletes the deployments at those routes instead.

It is the script form of Edge: Deploy (Ctrl+S / ⌘+S), Edge: Deploy with Message… and Edge: Delete…. It returns a Promise that resolves to a result object: check ok first, and then response.D for each route.

Syntax

js
await edge.save.limit()
await edge.save.limit(options)

Parameters

options Optional

An object with these properties:

message Optional

A note for this deployment. It is converted to a string, and an empty value sends no note. The note is shown as 💬 in the list of versions and returned as message by edge.versions(). The platform joins every run of whitespace, including newlines, into one space, so a note is always a single line. The length is not limited, but keep it to one short line, about 200 characters. With path: '/del' the note is kept with the deletion Experimental.

path Optional

A string that selects the action. '/put', the default, deploys. '/del' deletes the deployments of every route in Code.D, like Edge: Delete…. Pass exactly one of the two: any other value selects the delete action.

confirmed Optional

A boolean value: true skips the confirmation dialog of a delete, Delete this deployment permanently?. It has no effect on a deploy. The default is false.

Return value

A Promise that resolves to a result object. Failures that the platform reports arrive in the result; they are not thrown.

js
{
  ok: true,           // true only when reason is 'success'
  action: 'deploy',   // or 'delete'
  reason: 'success',  // or 'error', 'busy', 'cancelled', 'missing-user', 'no-routes'
  response: {         // not present for busy, cancelled, missing-user and no-routes
    D: { 'my-site': { success: true } }   // one entry per route
  }
}
ok

A boolean value: true only when reason is 'success'.

action

'deploy' or 'delete'.

reason

Why the call ended:

'success'

The deploy service answered without a global error. This does not mean that every route succeeded: read response.D.

'error'

The request failed. The cause is in error.

'busy'

A deploy or delete was already running. No request was sent.

'cancelled'

You closed the Code dialog or the delete confirmation without confirming.

'missing-user'

You are not signed in. The account dialog opens, and the call resolves at once.

'no-routes'

A delete was requested while Code.D is empty.

response Optional

An object, present when the deploy service answered. Its D member has one entry per route: { success: true, … } for a route that was published or deleted, or { error } for a route that failed. File bodies are replaced by the string '<REDACTED>'. Members other than D are not part of the API and may change.

error Optional

A string, or an array of { message, route?, domain?, … } objects for failures of single routes. See Exceptions.

retried Optional

true when the result comes from the automatic retry described in Usage notes.

Exceptions

The promise does not reject for failures that the platform reports. They arrive as reason: 'error', with the cause in error, or as one of the other reasons. These messages occur in a deploy or a delete:

MessageMeaning
route is not yoursAnother account owns the route, or you are an editor whose Editors list differs from the deployed one. Carries route. One foreign route stops the whole call.
common owner requiredAll routes of one deploy must have the same owner. Carries routes and owners.
storage quota exhaustedThe account's deployment quota is used up: the total size of its deployments or the number of its edge workers. The message does not say which. Carries account. See Limits and quotas.
invalid old sizeAnother deploy changed the route in the meantime. Try again.
route domain is not yoursThe route's domain is claimed by another account. Carries route and domain. A domain that nobody has claimed yet is claimed for you instead; see Usage notes.
NOT_SIGNED_IN_AS_OWNERYour session no longer matches your account. The playground shows Your session has expired. Sign in again to deploy! and signs you out.
Edge network is not available for public.The platform's answer was not JSON. This is a string, not an object.

A request that takes longer than 60 seconds ends with an error as well. Deploy requests sent too quickly show Rate limit hit. Try again later! in a toast.

Usage notes

Examples

Deploying and checking each route

Write this to io.eval.js and read io.eval.json. It lists one outcome per route, because ok alone is not enough.

js
const r = await edge.save.limit({ message: 'Tighten hero spacing' });
r.ok ? Object.entries(r.response.D).map(([route, v]) => [route, v.error ?? (v.success ? 'deployed' : 'not deployed')]) : r

Deleting the deployments

js
await edge.save.limit({ path: '/del' })                   // asks for confirmation
await edge.save.limit({ path: '/del', confirmed: true })  // does not ask

Specifications

Not part of any specification. edge.save.limit() is an RTCode.io playground function that deploys to RTEdge.net.

Availability

FeaturePlaygroundRTEdge.netNotes
edge.save.limit()YesNoNeeds a signed-in account and at least one route. Opens dialogs when a route is missing or wrong.
messageYesNoOn a delete, the note is Experimental.
path: '/del'YesNoOwner only. Asks for confirmation unless confirmed: true.

See also