UNPKG

trigger.dev

Version:

A Command-Line Interface for Trigger.dev projects

22 lines • 923 B
const RUN_TOKEN_ENV_KEY = "TRIGGER_RUN_TOKEN"; /** * Installs a refreshed run token only into the attempt it was minted for. A reused task process may * already be running another run or attempt, and must keep that execution's credential. */ export function installRunToken(current, update, env = process.env) { if (current?.run.id !== update.runId || current.attempt.number !== update.attemptNumber) { return false; } env[RUN_TOKEN_ENV_KEY] = update.token; return true; } /** * A warm-started process inherits the previous run's environment. When the next attempt carries no * run token, drop the inherited one so the SDK falls back instead of using another run's token. */ export function dropInheritedRunToken(executionEnv, env = process.env) { if (!Object.hasOwn(executionEnv, RUN_TOKEN_ENV_KEY)) { delete env[RUN_TOKEN_ENV_KEY]; } } //# sourceMappingURL=runTokenEnv.js.map