An entry for the streamplace vod showcase
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(runner): endpoint limits override global, improved dev logging

- Change mergeLimits to let endpoint limits override global (not min)
- Cap endpoint limits against runner's maxLimits
- Add detailed endpoint metadata logging in dev mode
- Increase Bun.serve idleTimeout to 255s (max allowed)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+31 -13
+23 -9
packages/at-run/runner/src/index.ts
··· 230 230 const permissions = filterPermissions(info.permissions, config.maxPermissions) 231 231 const limits = capLimits(info.limits, config.maxLimits) 232 232 233 - if (DEV_MODE) { 234 - console.log(`[sandbox] Bundle: ${bundlePath}`) 235 - console.log(`[sandbox] Permissions:`, permissions) 236 - console.log(`[sandbox] Limits:`, limits) 237 - console.log(`[sandbox] Endpoints:`, Object.keys(info.endpoints)) 238 - } 239 - 240 233 if (!info.endpoints[endpointName]) { 241 234 return Response.json( 242 235 { error: `Endpoint not found: ${endpointName}`, available: Object.keys(info.endpoints) }, ··· 244 237 ) 245 238 } 246 239 240 + const endpointInfo = info.endpoints[endpointName] 241 + 242 + if (DEV_MODE) { 243 + console.log("\n" + "=".repeat(60)) 244 + console.log(`[dev] Endpoint: ${endpointName}`) 245 + console.log("=".repeat(60)) 246 + console.log(`[dev] Bundle: ${bundlePath}`) 247 + console.log(`[dev] Author: ${authorDid || "unknown"}`) 248 + console.log(`[dev] Bundle name: ${bundleName || "unknown"}`) 249 + console.log(`[dev] Args:`, JSON.stringify(args, null, 2)) 250 + console.log(`[dev] Global permissions:`, permissions) 251 + console.log(`[dev] Endpoint permissions:`, endpointInfo.permissions || "(inherits global)") 252 + console.log(`[dev] Global limits:`, limits) 253 + console.log(`[dev] Endpoint limits:`, endpointInfo.limits || "(inherits global)") 254 + console.log(`[dev] Available endpoints:`, Object.keys(info.endpoints)) 255 + console.log("=".repeat(60) + "\n") 256 + } 257 + 247 258 // Fetch secrets if runner has a keypair and we know the author 248 259 let secrets: Record<string, string> = {} 249 260 if (runnerKeyPair && runnerDid && authorDid && bundleName) { ··· 259 270 } 260 271 } 261 272 262 - const endpointInfo = info.endpoints[endpointName] 273 + // Cap endpoint limits against runner's max as well 274 + const endpointLimits = capLimits(endpointInfo.limits, config.maxLimits) 275 + 263 276 result = await executeInSandbox({ 264 277 bundlePath, 265 278 endpointName, ··· 267 280 globalPermissions: permissions, 268 281 endpointPermissions: endpointInfo.permissions, 269 282 globalLimits: limits, 270 - endpointLimits: endpointInfo.limits, 283 + endpointLimits, 271 284 secrets, 272 285 }) 273 286 } else { ··· 474 487 export default { 475 488 port: PORT, 476 489 fetch: app.fetch, 490 + idleTimeout: 255, // Bun's max 477 491 }
+8 -4
packages/at-run/runtime/src/index.ts
··· 277 277 } 278 278 279 279 /** 280 - * Merge resource limits, taking the minimum (most restrictive) 280 + * Merge resource limits - endpoint limits override global limits 281 281 */ 282 - export function intersectLimits( 282 + export function mergeLimits( 283 283 global: ResourceLimits | undefined, 284 284 endpoint: ResourceLimits | undefined 285 285 ): Required<ResourceLimits> { ··· 287 287 288 288 if (!endpoint) return base 289 289 290 + // Endpoint limits override global limits 290 291 return { 291 - maxMemoryMB: Math.min(base.maxMemoryMB, endpoint.maxMemoryMB ?? Infinity), 292 - timeoutMs: Math.min(base.timeoutMs, endpoint.timeoutMs ?? Infinity), 292 + maxMemoryMB: endpoint.maxMemoryMB ?? base.maxMemoryMB, 293 + timeoutMs: endpoint.timeoutMs ?? base.timeoutMs, 293 294 } 294 295 } 296 + 297 + // Keep old name for backwards compatibility 298 + export const intersectLimits = mergeLimits 295 299 296 300 /** 297 301 * Convert permissions to Deno CLI flags