Skip to content

Optionally disable run debug logs #2116

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 5 commits into from
May 29, 2025
Merged

Optionally disable run debug logs #2116

merged 5 commits into from
May 29, 2025

Conversation

nicktrn
Copy link
Collaborator

@nicktrn nicktrn commented May 28, 2025

  • Controlled via supervisor env var: SEND_RUN_DEBUG_LOGS
  • Permanently disabled at the webapp route level for dev runs
  • Also replaces webapp health check with a more lightweight sql query

Copy link

changeset-bot bot commented May 28, 2025

🦋 Changeset detected

Latest commit: e5e901f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented May 28, 2025

Walkthrough

This change introduces a configuration option to control the sending of run debug logs within the supervisor component. A new environment variable, SEND_RUN_DEBUG_LOGS, is added and defaults to false. Related classes and types are updated to accept and propagate this flag, allowing the disabling of debug log transmission at runtime. API endpoints and HTTP client logic are modified to conditionally bypass debug log handling when the flag is unset. Additionally, the debug log API route in the web application is simplified to always return a 204 response without processing, and the healthcheck route’s database query is optimized. No existing logic or error handling is otherwise altered.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 1

🔭 Outside diff range comments (1)
apps/supervisor/src/workloadServer/index.ts (1)

581-603: ⚠️ Potential issue

Inconsistent debug log handling in notifyRun method.

The notifyRun method calls sendDebugLog without checking the env.SEND_RUN_DEBUG_LOGS flag, which means debug logs will still be sent from this method even when the feature is disabled. This undermines the purpose of the feature flag.

Apply this pattern to make the debug log calls consistent:

-      this.workerClient.sendDebugLog(run.friendlyId, {
-        time: new Date(),
-        message: "run:notify socket not found on supervisor",
-      });
+      if (env.SEND_RUN_DEBUG_LOGS) {
+        this.workerClient.sendDebugLog(run.friendlyId, {
+          time: new Date(),
+          message: "run:notify socket not found on supervisor",
+        });
+      }

Apply similar conditional checks to the other sendDebugLog calls in this method (lines 592-595 and 599-602).

🧹 Nitpick comments (2)
apps/webapp/app/routes/engine.v1.dev.runs.$runFriendlyId.logs.debug.ts (1)

77-79: Consider making this endpoint configurable instead of permanently disabled.

Unlike other components in this PR that use the SEND_RUN_DEBUG_LOGS environment variable for configuration, this endpoint is permanently disabled. Consider making it configurable for consistency and flexibility.

+import { env } from "~/env.server"; // Add environment import
+
 export function action() {
+  // Make this configurable like other components
+  if (!env.SEND_RUN_DEBUG_LOGS) {
     return new Response(null, { status: 204 });
+  }
+  
+  // Could restore original functionality here if needed
+  return new Response(null, { status: 204 });
 }
packages/core/src/v3/runEngineWorker/supervisor/http.ts (1)

36-36: Good addition of the configuration property.

The property is properly encapsulated as private readonly, which is appropriate for configuration that's set at initialization time.

Consider adding a documentation comment to clarify the property's purpose:

+ /** Whether to send run debug logs to the API */
  private readonly sendRunDebugLogs: boolean;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 82e7484 and e5e901f.

📒 Files selected for processing (9)
  • .changeset/fuzzy-snakes-beg.md (1 hunks)
  • apps/supervisor/src/env.ts (1 hunks)
  • apps/supervisor/src/index.ts (1 hunks)
  • apps/supervisor/src/workloadServer/index.ts (2 hunks)
  • apps/webapp/app/routes/engine.v1.dev.runs.$runFriendlyId.logs.debug.ts (1 hunks)
  • apps/webapp/app/routes/healthcheck.tsx (1 hunks)
  • packages/core/src/v3/runEngineWorker/supervisor/http.ts (3 hunks)
  • packages/core/src/v3/runEngineWorker/supervisor/session.ts (1 hunks)
  • packages/core/src/v3/runEngineWorker/supervisor/types.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/supervisor/src/env.ts (1)
apps/supervisor/src/envUtil.ts (1)
  • BoolEnv (6-12)
apps/supervisor/src/workloadServer/index.ts (1)
apps/supervisor/src/env.ts (1)
  • env (93-93)
apps/webapp/app/routes/healthcheck.tsx (1)
apps/webapp/app/db.server.ts (1)
  • prisma (100-100)
⏰ Context from checks skipped due to timeout of 90000ms (25)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (10, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (9, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 10)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 10)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 10)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 10)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: typecheck / typecheck
  • 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 - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
apps/webapp/app/routes/healthcheck.tsx (1)

6-6: Excellent performance optimization for health check!

Replacing prisma.user.count() with prisma.$queryRawSELECT 1`` is a smart improvement. This change:

  • Eliminates the overhead of counting potentially millions of user records
  • Provides the same database connectivity verification
  • Uses a lightweight constant query that executes quickly
  • Maintains the same error handling behavior

This is a standard pattern for health check endpoints and will significantly improve response times.

.changeset/fuzzy-snakes-beg.md (1)

1-6: Well-documented changeset entry.

The changeset correctly documents the patch to @trigger.dev/core package and provides a clear, concise description of the new HTTP client option for disabling debug logs.

packages/core/src/v3/runEngineWorker/supervisor/session.ts (1)

24-24:

✅ Verification successful

Good addition of the debug log control option.

The sendRunDebugLogs?: boolean property is correctly added to the type definition. The optional nature ensures backward compatibility.

Let me verify that this new option is properly passed through to the HTTP client:


🏁 Script executed:

#!/bin/bash
# Description: Verify that sendRunDebugLogs is properly passed from session options to HTTP client
# Expected: The option should be passed to SupervisorHttpClient constructor

# Search for SupervisorHttpClient constructor usage in this file
rg -A 5 -B 5 "new SupervisorHttpClient" packages/core/src/v3/runEngineWorker/supervisor/session.ts

# Search for how the option is used in the HTTP client
rg -A 10 "sendRunDebugLogs" packages/core/src/v3/runEngineWorker/supervisor/

Length of output: 5041


Confirmed: sendRunDebugLogs Is Properly Passed Through

  • In session.ts, the entire opts object—including the optional sendRunDebugLogs flag—is forwarded to new SupervisorHttpClient(opts).
  • In http.ts, the constructor reads opts.sendRunDebugLogs and defaults it to false (this.sendRunDebugLogs = opts.sendRunDebugLogs ?? false), then conditionally sends debug logs only when set to true.

No further changes needed.

apps/supervisor/src/env.ts (1)

90-90: Well-implemented environment variable addition.

The SEND_RUN_DEBUG_LOGS environment variable is properly implemented:

  • Uses the existing BoolEnv schema for consistent boolean handling
  • Defaults to false, which is appropriate for a debug feature
  • Logically placed in the Debug section with other debug-related variables
  • Follows the established naming convention

The BoolEnv schema properly handles string-to-boolean conversion, accepting "true"/"1" as true and other values as false.

packages/core/src/v3/runEngineWorker/supervisor/types.ts (1)

9-9: LGTM! Clean type definition for the new feature flag.

The optional boolean property is well-named and appropriately typed for controlling debug log transmission.

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

133-133: LGTM! Correct implementation of environment variable passing.

The configuration is properly passed to the SupervisorSession constructor, enabling runtime control of debug log sending.

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

378-380: LGTM! Correct conditional logic for disabling debug log sending.

The environment flag check properly prevents debug log transmission when the feature is disabled.

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

45-45: LGTM! Proper initialization with sensible default.

The use of nullish coalescing with false as the default is appropriate, ensuring debug logs are disabled by default while allowing explicit enablement when needed.


209-211: Excellent implementation of the conditional debug log sending.

The early return pattern efficiently avoids network calls when debug logs are disabled, improving performance without affecting the existing error handling logic.

@ericallam ericallam merged commit fda9565 into main May 29, 2025
35 checks passed
@ericallam ericallam deleted the fix/debug-logs branch May 29, 2025 08:32
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