mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-19 16:39:50 +00:00
fix: resolve undefined variable refs in billing retry paths (#2335)
Five undefined variable references across three cloud modules caused billing retry paths to silently fail: - digitalocean: doToken, doDropletId, doServerIp → _state.token/dropletId/serverIp - gcp: gcpProject → _state.project - aws: instanceName → _state.instanceName These caused checkAccountStatus() and checkBillingEnabled() to always return early, and billing retry saves to use wrong/undefined values. Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4f528b1c77
commit
bfef29a1b3
3 changed files with 12 additions and 12 deletions
|
|
@ -883,7 +883,7 @@ export async function createInstance(name: string, tier?: CloudInitTier): Promis
|
|||
"--user-data",
|
||||
userdata,
|
||||
]);
|
||||
instanceName = name;
|
||||
_state.instanceName = name;
|
||||
logInfo(`Instance creation initiated: ${name}`);
|
||||
return;
|
||||
}
|
||||
|
|
@ -934,7 +934,7 @@ export async function createInstance(name: string, tier?: CloudInitTier): Promis
|
|||
userData: userdata,
|
||||
}),
|
||||
);
|
||||
instanceName = name;
|
||||
_state.instanceName = name;
|
||||
logInfo(`Instance creation initiated: ${name}`);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ async function testDoToken(): Promise<boolean> {
|
|||
* Throws if the account is locked (billing issue). Warns on other statuses.
|
||||
*/
|
||||
export async function checkAccountStatus(): Promise<void> {
|
||||
if (!doToken) {
|
||||
if (!_state.token) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
|
@ -886,13 +886,13 @@ export async function createServer(
|
|||
const retryText = await doApi("POST", "/droplets", body);
|
||||
const retryData = parseJsonObj(retryText);
|
||||
if (retryData?.droplet?.id) {
|
||||
doDropletId = String(retryData.droplet.id);
|
||||
logInfo(`Droplet created: ID=${doDropletId}`);
|
||||
await waitForDropletActive(doDropletId);
|
||||
_state.dropletId = String(retryData.droplet.id);
|
||||
logInfo(`Droplet created: ID=${_state.dropletId}`);
|
||||
await waitForDropletActive(_state.dropletId);
|
||||
saveVmConnection(
|
||||
doServerIp,
|
||||
_state.serverIp,
|
||||
"root",
|
||||
doDropletId,
|
||||
_state.dropletId,
|
||||
name,
|
||||
"digitalocean",
|
||||
undefined,
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ export async function resolveProject(): Promise<void> {
|
|||
* Throws if billing is not enabled (so orchestrate.ts can catch and continue).
|
||||
*/
|
||||
export async function checkBillingEnabled(): Promise<void> {
|
||||
if (!gcpProject) {
|
||||
if (!_state.project) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
|
@ -529,12 +529,12 @@ export async function checkBillingEnabled(): Promise<void> {
|
|||
"billing",
|
||||
"projects",
|
||||
"describe",
|
||||
gcpProject,
|
||||
_state.project,
|
||||
"--format=value(billingEnabled)",
|
||||
]);
|
||||
const output = result.stdout.trim().toLowerCase();
|
||||
if (output === "false") {
|
||||
logWarn(`Billing is not enabled for project '${gcpProject}'.`);
|
||||
logWarn(`Billing is not enabled for project '${_state.project}'.`);
|
||||
const shouldRetry = await handleBillingError("gcp");
|
||||
if (!shouldRetry) {
|
||||
throw new Error("GCP billing not enabled");
|
||||
|
|
@ -544,7 +544,7 @@ export async function checkBillingEnabled(): Promise<void> {
|
|||
"billing",
|
||||
"projects",
|
||||
"describe",
|
||||
gcpProject,
|
||||
_state.project,
|
||||
"--format=value(billingEnabled)",
|
||||
]);
|
||||
if (retry.stdout.trim().toLowerCase() === "false") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue