space.schedule.run()

Start a run of a job straight away, whatever its schedule.

Starts a run of a job straight away, whatever its schedule. The run’s trigger is manual.

function run(id: string, options?: CallOptions): Promise<Run>

Parameters

idstringRequired

The job’s ID: 26 lowercase letters and digits.

options.signalAbortSignal

Cancels the call.

options.timeoutMsnumber

How long the call may take, in milliseconds. The timeoutMs set in createSpace when you leave it out, 30,000 by default.

Returns

A promise of the new run. It returns once the run is created, not when it finishes; read it later with getRun() to see how it went.

run() is never sent again once the run may have started, so a network failure, a timeout, or a 502 does not start a second run. It is sent again, up to retries times, only when it was refused with 429 or 503 before any work began.

Errors

CodeWhen
validation_failedid is not a job ID
not_foundThe project has no job with that ID
run_in_progressThe job already has a run that has not finished

Every call can also fail with the codes shared by all of space, such as missing_project or network_error. See SpaceError.

Example

run-now.ts
import { space, SpaceError } from "digitospace"

try {
  const run = await space.schedule.run("01m3c081d2wj4g63qcr53pa1yh")
  console.log(run.id, run.status)
} catch (error) {
  if (error instanceof SpaceError && error.code === "run_in_progress") {
    console.log("The job is already running.")
  } else {
    throw error
  }
}

Last updated