Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix controller waitpoint resolution, suspendable state, and snapshot race conditions #2006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 69 commits into from
May 7, 2025

Conversation

nicktrn
Copy link
Collaborator

@nicktrn nicktrn commented May 1, 2025

Quite a few things in here:

  • Fix testcontainer unit tests (first attempt..)
  • Remove a lot of dead code
  • Add snapshot queue tests
  • Add debug logs to runtime manager
  • Fix entitlement validation when no client exists
  • Correctly resolve waitpoints that come in early
  • Ensure correct state before requesting suspension
  • Fix race conditions in snapshot processing
  • New snapshots since engine method and webapp route
  • Add run execution deprecation detection
  • Update connection settings after restores
  • Fix restore detection (moved to snapshot manager)

We now require two things before suspending a run:

  1. The execution status needs to be either EXECUTING_WITH_WAITPOINTS or QUEUED_EXECUTING
  2. The runtime manager needs to signal it's "suspendable"
  3. These events can happen out of order

Summary by CodeRabbit

  • New Features

    • Added ability to fetch execution snapshots since a given snapshot, with new API routes and client methods in backend and webapp.
    • Introduced a SnapshotManager and RunNotifier to centralize snapshot state and notification handling.
    • Added a new ConsoleRunLogger and enhanced debug logging capabilities.
    • Deployment logs now always print fully in CI environments.
  • Bug Fixes

    • Improved handling of early-arriving waitpoints and race conditions during snapshot processing.
    • Ensured proper state before suspension requests and fixed concurrency issues.
  • Refactor

    • Replaced ManagedRuntimeManager with SharedRuntimeManager for better waitpoint management.
    • Simplified event and IPC message handling by removing obsolete wait-related events and messages.
    • Refactored snapshot polling to delegate handling externally and improved internal metrics tracking.
    • Enhanced environment variable overrides and socket event handling with improved error and disconnect management.
  • Tests

    • Added extensive tests for SnapshotManager and snapshot retrieval since a given snapshot.
    • Added tests verifying getSnapshotsSince behavior and error handling.
  • Chores

    • Updated TypeScript configs to exclude test files from source builds and added a test config.
    • Improved error output in publishing scripts.
    • Enhanced deployment command output formatting for CI and non-CI environments.
  • Documentation

    • Updated change logs to reflect CI logging behavior changes.

@nicktrn nicktrn marked this pull request as draft May 2, 2025 13:57
@nicktrn nicktrn marked this pull request as ready for review May 6, 2025 21:47
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (10)
apps/supervisor/src/workloadServer/index.ts (1)

345-369: Implementation follows consistent pattern with other endpoints

The new endpoint to fetch snapshots since a specific snapshot ID is well-structured and follows the established patterns in the codebase. It properly validates parameters, handles error cases, and returns appropriately typed responses.

One small suggestion to improve error logging:

if (!sinceSnapshotResponse.success) {
  console.error("Failed to get snapshots since", {
    runId: params.runFriendlyId,
+   snapshotId: params.snapshotFriendlyId,
    error: sinceSnapshotResponse.error,
  });
  reply.empty(500);
  return;
}
apps/webapp/app/routes/engine.v1.worker-actions.runs.$runFriendlyId.snapshots.since.$snapshotId.ts (1)

1-30: Well-structured API route for snapshot retrieval

This new route handler for retrieving snapshots is cleanly implemented using the createLoaderWorkerApiRoute helper. It correctly validates parameters and uses the authenticated worker API client to fetch snapshots since a specified ID.

The error handling is functional but could be more specific about the type of failure.

Consider enhancing the error message to be more specific:

if (!snapshots) {
-  throw new Error("Failed to retrieve snapshots since given snapshot");
+  throw new Error(`Failed to retrieve snapshots since snapshot ${snapshotId} for run ${runFriendlyId}`);
}
internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts (1)

45-60: Unnecessary index === -1 check + O(n²) scan – simplify and speed-up.

indexes is never populated with -1, so the ternary adds no value and slightly obscures intent.
Additionally, scanning completedWaitpointOrder for every wait-point yields O(N·M) behaviour (N = waitpoints, M = order length). A single Map<id,index> built once would turn this into O(N).

-          index: index === -1 ? undefined : index,
+          // `index` is already either a valid number or `undefined`
+          index,

Consider pre-building a lookup:

const orderIndex = new Map<string, number>();
snapshot.completedWaitpointOrder.forEach((id, i) => orderIndex.set(id, i));

index: orderIndex.get(w.id),
packages/cli-v3/src/entryPoints/managed/controller.ts (2)

34-36: notificationCount & lastNotificationAt are never updated

The counters are declared and surfaced via metrics, but no code now mutates them after the removal of "run:notify" listeners.
Consider deleting these members or moving the increment logic into RunNotifier to avoid stale or misleading metrics.


465-472: Environment diff logging shows identical objects

currentEnv and newEnv are constructed from the same runtime values, making the diff in the debug log uninformative.
If the intention is to capture override effects, build newEnv after calling processEnvOverrides and from the mutated source.

packages/cli-v3/src/executions/taskRunProcess.ts (2)

101-108: unsafeDetachEvtHandlers() relies on caller discipline

Detaching every handler is powerful but dangerous: forgetting to call it when disposing the instance will leak listeners and promises.
Consider invoking it inside kill()/cleanup() once the child has exited, or wrapping the Evt instances in a disposable object to enforce cleanup.


404-408: Error path in kill() swallows important diagnostics

console.debuging the caught error is fine for dev, but production troubleshooting benefits from propagating or logging at warn/error level so it surfaces in monitoring.

-      logger.debug("kill: failed to kill child process", { error });
+      logger.warn?.("kill: failed to kill child process", { error });
packages/cli-v3/src/entryPoints/managed/snapshot.ts (1)

338-359: hasBeenRestored performs a remote call on every snapshot – cache result

hasBeenRestored() reaches out to the MetadataClient for every deprecated snapshot detection, which (a) adds latency inside the queue loop, and (b) hammers the metadata service under high-frequency snapshot traffic.

Since a run can only be “restored” once per execution, you can safely cache the first non-null TRIGGER_RUNNER_ID comparison and short-circuit subsequent calls.

+private _restored?: boolean;
...
if (this._restored !== undefined) {
  return this._restored;
}
const [error, overrides] = await this.metadataClient.getEnvOverrides();
...
this._restored = restored;
return restored;

This keeps the logic intact while eliminating N redundant network round-trips.

packages/cli-v3/src/entryPoints/managed/execution.ts (2)

683-690: Redundant self-check inside case "RETRY_IMMEDIATELY"

Inside the "RETRY_IMMEDIATELY" branch you re-verify
if (attemptStatus !== "RETRY_IMMEDIATELY") { return; }, which can never be true because we are already in that case label. This is dead code that obscures the intent.

Please remove the redundant guard.


920-931: Log helper may emit "snapshotId": undefined before manager initialisation

sendDebugLog always injects snapshotId: this.currentSnapshotFriendlyId, but many early logs (constructor, cancel, etc.) are executed before the SnapshotManager is created, resulting in noisy undefined fields.

Consider suppressing the property when not yet available:

properties: {
  ...properties,
  runId: this.runFriendlyId,
- snapshotId: this.currentSnapshotFriendlyId,
+ ...(this.currentSnapshotFriendlyId && { snapshotId: this.currentSnapshotFriendlyId }),
  ...
}

This keeps the log payload clean and avoids confusion during debugging.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed1a44c and 188a023.

📒 Files selected for processing (25)
  • apps/supervisor/src/workloadServer/index.ts (2 hunks)
  • apps/webapp/app/routes/engine.v1.worker-actions.runs.$runFriendlyId.snapshots.since.$snapshotId.ts (1 hunks)
  • apps/webapp/app/v3/services/worker/workerGroupTokenService.server.ts (1 hunks)
  • internal-packages/run-engine/src/engine/index.ts (2 hunks)
  • internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts (4 hunks)
  • internal-packages/run-engine/src/engine/tests/waitpoints.test.ts (1 hunks)
  • packages/cli-v3/package.json (2 hunks)
  • packages/cli-v3/src/commands/deploy.ts (7 hunks)
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts (3 hunks)
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts (3 hunks)
  • packages/cli-v3/src/entryPoints/managed/controller.ts (12 hunks)
  • packages/cli-v3/src/entryPoints/managed/env.ts (3 hunks)
  • packages/cli-v3/src/entryPoints/managed/execution.ts (31 hunks)
  • packages/cli-v3/src/entryPoints/managed/notifier.ts (1 hunks)
  • packages/cli-v3/src/entryPoints/managed/overrides.ts (2 hunks)
  • packages/cli-v3/src/entryPoints/managed/poller.ts (5 hunks)
  • packages/cli-v3/src/entryPoints/managed/snapshot.test.ts (1 hunks)
  • packages/cli-v3/src/entryPoints/managed/snapshot.ts (1 hunks)
  • packages/cli-v3/src/executions/taskRunProcess.ts (8 hunks)
  • packages/core/src/v3/runEngineWorker/supervisor/http.ts (2 hunks)
  • packages/core/src/v3/runEngineWorker/supervisor/schemas.ts (2 hunks)
  • packages/core/src/v3/runEngineWorker/workload/http.ts (2 hunks)
  • packages/core/src/v3/runEngineWorker/workload/schemas.ts (2 hunks)
  • packages/core/src/v3/schemas/messages.ts (3 hunks)
  • packages/core/src/v3/serverOnly/httpServer.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/core/src/v3/runEngineWorker/workload/schemas.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/cli-v3/package.json
  • packages/cli-v3/src/entryPoints/dev-run-worker.ts
  • packages/cli-v3/src/commands/deploy.ts
  • packages/cli-v3/src/entryPoints/managed-run-worker.ts
  • packages/cli-v3/src/entryPoints/managed/env.ts
  • packages/core/src/v3/schemas/messages.ts
  • packages/core/src/v3/runEngineWorker/supervisor/schemas.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/cli-v3/src/entryPoints/managed/notifier.ts (2)
packages/cli-v3/src/entryPoints/managed/controller.ts (1)
  • SupervisorSocket (21-21)
packages/cli-v3/src/entryPoints/managed/logger.ts (2)
  • RunLogger (17-19)
  • SendDebugLogOptions (9-15)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (46)
apps/webapp/app/v3/services/worker/workerGroupTokenService.server.ts (1)

762-773: Clean implementation of snapshot retrieval.

The new getSnapshotsSince method follows the established pattern of other methods in this class, properly converting friendly IDs to internal IDs before calling the engine.

packages/core/src/v3/runEngineWorker/supervisor/http.ts (2)

20-20: LGTM: Import addition for new snapshot feature.

The import of WorkerApiRunSnapshotsSinceResponseBody supports the new snapshot retrieval functionality.


189-201: Well-structured HTTP client method.

The implementation follows the established pattern in this class for HTTP client methods, with proper request construction and response validation.

packages/core/src/v3/runEngineWorker/workload/http.ts (2)

14-14: LGTM: Import addition for new snapshot feature.

The import of WorkloadRunSnapshotsSinceResponseBody supports the new snapshot retrieval functionality.


146-157: Consistent implementation of snapshot retrieval.

The getSnapshotsSince method follows the same pattern as other HTTP methods in this class, with appropriate error handling via the wrapZodFetch utility.

packages/core/src/v3/serverOnly/httpServer.ts (3)

204-204: Improved error formatting for better logging.

Using the new formatError method provides more structured and consistent error logs.


213-213: Improved error formatting for better logging.

Using the new formatError method provides more structured and consistent error logs.


368-378: Good error formatting utility.

This helper method improves error logging by providing a consistent structure for different error types. It properly extracts name, message, and stack from Error objects while handling non-Error values gracefully.

apps/supervisor/src/workloadServer/index.ts (1)

20-20: Import addition looks good

Clean addition of the WorkloadRunSnapshotsSinceResponseBody import to support the new route.

packages/cli-v3/src/entryPoints/managed/overrides.ts (2)

2-3: Added metadata properties for run and snapshot tracking

The addition of TRIGGER_RUN_ID and TRIGGER_SNAPSHOT_ID properties to the Metadata type provides a clean way to track run and snapshot context across the managed runtime.


22-33: Improved error handling in getEnvOverrides

This refactoring changes the return type to a discriminated union tuple, improving error handling and transparency. The implementation now explicitly checks response status and properly propagates errors rather than logging and returning null.

This makes error handling more predictable for consumers of this API.

internal-packages/run-engine/src/engine/tests/waitpoints.test.ts (1)

1348-1490: Comprehensive test coverage for the new getSnapshotsSince functionality

This test is well-structured and thoroughly tests the getSnapshotsSince method with various inputs and edge cases. It properly:

  1. Creates multiple snapshots by triggering a run and using waitpoints
  2. Verifies that snapshots returned contain expected data
  3. Tests behavior with the first snapshot ID, latest snapshot ID, and invalid IDs
  4. Checks specific properties like completedWaitpoints and error handling

The test ensures proper cleanup by quitting the engine instance in a finally block, which is good practice.

packages/cli-v3/src/entryPoints/managed/notifier.ts (6)

1-12: Well-structured interface design for the RunNotifier

The notifier options interface and dependencies are clearly defined with appropriated types. This makes the notifier component easy to integrate and configure.


13-30: Good class structure with clean property initialization

The class properties are properly typed and initialized, clearly distinguishing between configuration properties and internal state tracking metrics.


32-64: Well-implemented start method with notification handling

The notification mechanism generates a unique ID for tracking, performs validation, and includes comprehensive debug logging. The chained return of this enables fluent API usage.

Consider enhancing the notification ID generation with a more robust unique ID approach if this needs to scale to high volumes of notifications:

- const notificationId = Math.random().toString(36).substring(2, 15);
+ const notificationId = `${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;

66-69: Clean stop method implementation

The stop method appropriately removes all listeners to prevent memory leaks and includes debug logging.


71-78: Good observability with metrics getter

The metrics getter provides a clean interface for external components to access notification statistics without exposing internal class properties directly.


80-89: Well-structured debug logging method

The private sendDebugLog method consistently formats logs and enriches them with metrics data, enhancing debuggability.

internal-packages/run-engine/src/engine/index.ts (3)

44-48: Enhanced imports for snapshot functionality

The additional imports for snapshot processing support the new functionality for retrieving snapshots since a given point.


1102-1112: Improved error handling in getRunExecutionData

The refactored method now uses the new executionDataFromSnapshot helper for consistent data transformation and includes proper error handling with detailed logging.


1114-1134: Well-implemented new getSnapshotsSince method

This method retrieves all execution snapshots since a specified ID, with appropriate error handling and consistent data transformation using the executionDataFromSnapshot helper.

packages/cli-v3/src/entryPoints/managed/poller.ts (10)

2-4: Good dependency management with clear type definition

The poller now uses the IntervalService for timing functionality and defines a clean OnPoll callback type.


11-12: Simplified interface with callback approach

The poller options now use a callback approach instead of direct dependency on the HTTP client, improving modularity.


19-25: Enhanced property definitions with metrics tracking

Added metrics tracking for polls, which improves observability.


32-33: Improved constructor with callback assignment

The constructor now assigns the onPoll callback instead of handling polling logic internally.


45-48: Good metrics tracking implementation

The poller now tracks metrics like lastPollAt and pollCount before invoking the callback.


64-67: Clear documentation on snapshotId usage

The comment clarifies that the snapshot ID is used as an indicator for stuck pollers, which helps with future maintenance.


73-85: Enhanced start method with fluent interface

The start method now returns this for method chaining and includes improved logging.


87-102: Improved stop method with execution status detection

The stop method now detects if the poller was executing during stop, which helps with debugging race conditions.


104-109: Added metrics getter for observability

The metrics getter provides a clean interface for accessing poll statistics.


111-122: Enhanced debug logging with metrics

The updated sendDebugLog method includes metrics in the log properties, which improves debugging capabilities.

packages/cli-v3/src/entryPoints/managed/snapshot.test.ts (9)

1-26: Well-structured test setup with mock dependencies

The test suite uses proper mocking and setup for the SnapshotManager tests.


27-111: Comprehensive basic functionality tests

The tests for initialization, snapshot updates, and suspendable state transitions provide good coverage of the core functionality.


112-210: Thorough queue processing tests

The tests for queue order, duplicate handling, and snapshot validation logic are well-implemented.


212-277: Excellent concurrency handling tests

The tests for preventing concurrent handler execution use timing verification to ensure handlers don't overlap.


279-365: Comprehensive error handling and cleanup tests

These tests verify proper behavior during errors and cleanup scenarios.


367-478: Thorough edge case handling

The tests for edge cases like empty IDs, long IDs, and high concurrency are well-designed to catch potential issues.


480-630: Well-structured queue processing tests

These tests verify proper queue processing behavior including rapid changes during processing.


632-699: Thorough runner restoration testing

The tests for detecting restored runners and handling deprecation markers are comprehensive.


702-734: Useful test helper function

The createRunExecutionData helper provides a clean way to generate test data with sensible defaults.

internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts (1)

198-218: Possible snapshot omission when two snapshots share the same createdAt

Filtering with createdAt > sinceSnapshot.createdAt can miss a snapshot generated in the same millisecond (ULID/Timestamp collisions on busy systems).
Safer options:

  1. Filter on (createdAt > …) OR (createdAt = … AND id > sinceSnapshotId) if IDs are monotonic.
  2. Simply request gt: sinceSnapshot.id when your ID encodes time.

Please verify whether duplicate timestamps are realistically possible with your DB adapter; adjust the query if necessary.

packages/cli-v3/src/entryPoints/managed/controller.ts (2)

196-198: Redundant removal of "run:notify" listeners

this.socket.removeAllListeners("run:notify") is executed, yet no listener is ever attached in this class any more (notification handling was delegated to RunNotifier).
Double-check that nothing else attaches that event to this socket; otherwise the call can be dropped.


397-399: kill() is asynchronous but process.exit() follows immediately

this.currentExecution?.kill() returns a promise that won’t settle once process.exit() is invoked, possibly leaving child processes around for a brief period.
Consider awaiting the promise with a modest timeout (or calling a synchronous kill) before exiting.

-    this.currentExecution?.kill().catch(() => {});
-    process.exit(code);
+    await Promise.race([
+      this.currentExecution?.kill().catch(() => {}),
+      new Promise(r => setTimeout(r, 2_000)) // fallback timeout
+    ]);
+    process.exit(code);
packages/cli-v3/src/executions/taskRunProcess.ts (2)

206-213: 👍 New event plumbing looks good

The handlers for SEND_DEBUG_LOG and SET_SUSPENDABLE are concise and forward messages via Evt – no issues spotted.


297-298: Verify peer support for "RESOLVE_WAITPOINT" message

The emitter now sends "RESOLVE_WAITPOINT". Ensure both the worker side and the updated SharedRuntimeManager handle this verb; otherwise waitpoint completion signalling will break silently.

packages/cli-v3/src/entryPoints/managed/snapshot.ts (1)

103-106: Potentially unsafe ordering check – string comparison may drop newer snapshots

snapshotId < this.state.id relies on lexicographical ordering of the friendlyId.
Unless you can guarantee that the ID scheme is strictly monotonic-sortable (e.g. ULIDs), the comparison may mis-classify a newer snapshot that happens to compare as “smaller” (common with CUID/cuid2). That would silently drop legitimate updates and stall the run.

-if (snapshotId < this.state.id) {
+// Prefer an explicit comparator that understands the ID format or,
+// if the IDs embed a timestamp, compare the timestamps instead.
+if (this.isOlderSnapshot(snapshotId, this.state.id)) {

Consider introducing a helper (isOlderSnapshot) that either decodes the timestamp portion or falls back to localeCompare with a formal guarantee.
Failing to do so could re-introduce the very race conditions this PR tries to eliminate.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
packages/core/src/v3/runtime/sharedRuntimeManager.ts (2)

261-265: Fix potential iteration issue when modifying the Map

The current implementation iterates over waitpointsByResolverId.entries() while potentially modifying the Map inside resolveWaitpoint(), which could lead to unpredictable behavior in some JavaScript engines.


284-306: Add defensive JSON parsing to handle malformed output

The JSON.parse call is not wrapped in a try-catch block, which could cause runtime errors if the output is not valid JSON.

🧹 Nitpick comments (5)
packages/core/src/v3/runtime/sharedRuntimeManager.ts (5)

39-41: Consider using a named constant instead of a magic number

The interval duration 300_000 (5 minutes in milliseconds) would be more maintainable if defined as a named constant at the top of the file or class.

+ private static readonly STATUS_LOG_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes
  constructor(
    private ipc: ExecutorToWorkerProcessConnection,
    private showLogs: boolean
  ) {
    // Log out the runtime status on a long interval to help debug stuck executions
    setInterval(() => {
      this.debugLog("SharedRuntimeManager status", this.status);
-    }, 300_000);
+    }, SharedRuntimeManager.STATUS_LOG_INTERVAL_MS);
  }

84-90: Unused reject parameter in Promise constructor

The Promise constructor receives a reject parameter that's never used. This can lead to confused developers and unhandled rejections.

  const promises = Array.from({ length: params.runCount }, (_, index) => {
    const resolverId = `${params.id}_${index}` as ResolverId;

-    return new Promise<CompletedWaitpoint>((resolve, reject) => {
+    return new Promise<CompletedWaitpoint>((resolve) => {
      this.resolversById.set(resolverId, resolve);
    });
  });

219-225: Document why BATCH waitpoints are ignored

While the code includes a comment about ignoring BATCH waitpoints, it would be helpful to document this design decision more clearly, especially if it might change in the future.

  if (waitpoint.type === "BATCH") {
-    // We currently ignore these, they're not required to resume after a batch completes
+    // BATCH waitpoints are intentionally ignored because batches are resumed via their individual task waitpoints
+    // Each task in the batch has its own waitpoint that is processed separately
+    // TODO: If this behavior changes in the future, update this implementation
    this.debugLog("ignoring BATCH waitpoint", {
      waitpoint: this.waitpointForDebugLog(waitpoint),
    });
    return;
  }

308-319: Consider optimizing debug log data structure

The method includes both ISO string representations and Date objects for timestamps, which is redundant and increases the log payload size.

  private waitpointForDebugLog(waitpoint: CompletedWaitpoint): DebugLogPropertiesInput {
    const { completedAfter, completedAt, output, ...rest } = waitpoint;

    return {
      ...rest,
      output: output?.slice(0, 100),
      completedAfter: completedAfter?.toISOString(),
      completedAt: completedAt?.toISOString(),
-      completedAfterDate: completedAfter,
-      completedAtDate: completedAt,
    };
  }

338-341: Consider unifying log methods

There are two separate logging methods (debugLog and log) with different behaviors. Consider unifying them or more clearly documenting their distinct purposes.

- private log(message: string, ...args: any[]) {
-   if (!this.showLogs) return;
-   console.log(`[${new Date().toISOString()}] ${message}`, args);
- }
+ /**
+  * Basic logging method for high-volume logs that don't need to be sent via IPC
+  * Use debugLog for important diagnostic information that should be available remotely
+  */
+ private log(message: string, ...args: any[]) {
+   if (!this.showLogs) return;
+   console.log(`[${new Date().toISOString()}] ${message}`, ...args);
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a27eea and 8c3da69.

📒 Files selected for processing (1)
  • packages/core/src/v3/runtime/sharedRuntimeManager.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/core/src/v3/runtime/sharedRuntimeManager.ts (5)
packages/core/src/v3/workers/index.ts (2)
  • SharedRuntimeManager (24-24)
  • RuntimeManager (2-2)
packages/core/src/v3/runtime/preventMultipleWaits.ts (1)
  • preventMultipleWaits (7-32)
packages/core/src/v3/lifecycle-hooks-api.ts (1)
  • lifecycleHooks (5-5)
packages/core/src/utils.ts (1)
  • assertExhaustive (1-3)
packages/core/src/v3/runEngineWorker/supervisor/schemas.ts (2)
  • DebugLogPropertiesInput (141-141)
  • DebugLogPropertiesInput (142-142)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
packages/core/src/v3/runtime/sharedRuntimeManager.ts (5)

169-213: Approved method for resolver ID determination

The resolver ID determination logic is comprehensive and handles all waitpoint types correctly with appropriate error handling and logging.


267-269: Approved simple suspendable state setter method

The setSuspendable method correctly sends an IPC message to communicate the suspendable state.


271-282: Approved suspendable wrapper with good error handling

The suspendable method implements a robust pattern for wrapping promises with suspendable state management and proper error handling.


321-336: Approved debug logging with runtime status

The debug logging implementation includes helpful runtime status information and properly sends logs through IPC for monitoring.


343-348: Approved runtime status implementation

The status getter provides a clean, serializable representation of the internal state for debugging purposes.

@nicktrn nicktrn merged commit 2b586c8 into main May 7, 2025
20 checks passed
@nicktrn nicktrn deleted the fix/resolve-waitpoints branch May 7, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants