mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 23:56:43 +01:00
fix(runtime): honor provider acquisition timeout defaults (#14097)
Declare provider acquisition budgets so slow Daytona creation does not hit the host’s 30-second fallback. Bound creation and setup to one deadline and preserve scoped cleanup ownership after timeout. Legacy drivers retain their original call shape. Validated by 238 provider/manifest tests, focused database and heartbeat regressions, root and standalone provider typecheck/build, and full CI. Local broad tests also expose recorded Mac baseline limitations. Greptile 5/5. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
7f3c06dac4
commit
ffa32373bc
9 files changed
+295
-77
No files matched your search
@@ -485,9 +485,16 @@ export interface EnvironmentDriverReleaseInput {
|
||||
status: Extract<EnvironmentLeaseStatus, "released" | "expired" | "failed">;
|
||||
}
|
||||
|
||||
function resolvePluginSandboxRpcTimeoutMs(config: Record<string, unknown>): number | undefined {
|
||||
function resolvePluginSandboxRpcTimeoutMs(
|
||||
config: Record<string, unknown>,
|
||||
defaultTimeoutMs?: number,
|
||||
): number | undefined {
|
||||
const configuredTimeoutMs = typeof config.timeoutMs === "number" &&
|
||||
Number.isFinite(config.timeoutMs) && config.timeoutMs > 0
|
||||
? config.timeoutMs
|
||||
: defaultTimeoutMs;
|
||||
const timeoutCandidates = [
|
||||
typeof config.timeoutMs === "number" ? config.timeoutMs : undefined,
|
||||
configuredTimeoutMs,
|
||||
typeof config.bridgeRequestTimeoutMs === "number" ? config.bridgeRequestTimeoutMs : undefined,
|
||||
]
|
||||
.filter((value): value is number => typeof value === "number" && Number.isFinite(value) && value > 0)
|
||||
@@ -2084,7 +2091,10 @@ function createSandboxEnvironmentDriver(
|
||||
? { requestedExpiresAt: requestedExpiresAtParam(input.requestedExpiresAt) }
|
||||
: {}),
|
||||
},
|
||||
resolvePluginSandboxRpcTimeoutMs(workerConfig),
|
||||
resolvePluginSandboxRpcTimeoutMs(
|
||||
workerConfig,
|
||||
pluginProvider.resolved.driver.defaultAcquireTimeoutMs,
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
const cleanup = readEnvironmentCreationCleanupError(error);
|
||||
@@ -3390,7 +3400,7 @@ function createPluginEnvironmentDriver(
|
||||
if (!workerManager.isRunning(plugin.id)) {
|
||||
throw new Error(`Plugin environment driver "${pluginDriverProviderKey(config)}" has no running worker.`);
|
||||
}
|
||||
return { plugin };
|
||||
return { plugin, driver };
|
||||
}
|
||||
|
||||
async function resolvePluginDriverForRelease(input: EnvironmentDriverReleaseInput) {
|
||||
@@ -3459,7 +3469,12 @@ function createPluginEnvironmentDriver(
|
||||
if (parsed.driver !== "plugin") {
|
||||
throw new Error(`Expected plugin environment config for driver "${input.environment.driver}".`);
|
||||
}
|
||||
const { plugin } = await resolvePluginDriver(parsed.config);
|
||||
const { plugin, driver } = await resolvePluginDriver(parsed.config);
|
||||
const rpcTimeoutMs = resolvePluginSandboxRpcTimeoutMs(
|
||||
parsed.config.driverConfig,
|
||||
driver.defaultAcquireTimeoutMs,
|
||||
);
|
||||
const timeoutOverride: [number?] = rpcTimeoutMs === undefined ? [] : [rpcTimeoutMs];
|
||||
const providerLease = await workerManager.call(plugin.id, "environmentAcquireLease", {
|
||||
driverKey: parsed.config.driverKey,
|
||||
companyId: input.companyId,
|
||||
@@ -3477,7 +3492,7 @@ function createPluginEnvironmentDriver(
|
||||
...(requestedExpiresAtParam(input.requestedExpiresAt) !== undefined
|
||||
? { requestedExpiresAt: requestedExpiresAtParam(input.requestedExpiresAt) }
|
||||
: {}),
|
||||
} as PluginEnvironmentAcquireLeaseParams);
|
||||
} as PluginEnvironmentAcquireLeaseParams, ...timeoutOverride);
|
||||
|
||||
return await environmentsSvc.acquireLease({
|
||||
companyId: input.companyId,
|
||||
|
||||
Reference in new issue
Block a user