Skip to content

Prettier errors and related improvements #1387

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 17 commits into from
Oct 9, 2024
Merged

Conversation

nicktrn
Copy link
Collaborator

@nicktrn nicktrn commented Oct 7, 2024

This improves a bunch of stuff:

  • No more crashes due to checkpoint readiness
  • Fixes to existing messages and links
  • Additional internal errors for OOM, disk space limits, and more
  • Prettier display of errors with links to docs

image

Summary by CodeRabbit

  • New Features

    • Enhanced error handling for task execution, allowing for more specific categorization of errors.
    • Introduced a new static method to process and structure error messages for improved user guidance.
  • Bug Fixes

    • Resolved various logging issues to ensure clearer error reporting during task execution and socket event handling.
  • Documentation

    • Updated links structure for clearer access to documentation resources.
  • Chores

    • Removed outdated utility files related to error handling and documentation links.

Copy link

changeset-bot bot commented Oct 7, 2024

🦋 Changeset detected

Latest commit: a3c6dc1

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

This PR includes changesets to release 4 packages
Name Type
trigger.dev Patch
@trigger.dev/core Patch
@trigger.dev/build Patch
@trigger.dev/sdk Patch

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 Oct 7, 2024

Walkthrough

This pull request introduces enhancements to error handling within the TaskRunProcess class in the taskRunProcess.ts file. Key changes include the addition of new imports for error codes and a method to parse and categorize execution errors. The parseExecuteError method processes various error types, ensuring structured error reporting. Additionally, the visibility of the pid getter is modified. Overall, these changes enhance the robustness and granularity of error management during task execution.

Changes

File Path Change Summary
packages/cli-v3/src/executions/taskRunProcess.ts Added parseExecuteError method for structured error processing, along with new imports for TaskRunErrorCodes and internalErrorFromUnexpectedExit, enhancing error handling capabilities. Modified visibility of the pid getter.

Possibly related PRs

Suggested reviewers

  • ericallam

🐰 In the meadow where we play,
Errors frolic, kept at bay.
With logs so clear, and links so bright,
Task runs dance in pure delight!
Let's hop along, with joy we cheer,
For every fix brings us more near! 🌼✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6e3dbd0 and a3c6dc1.

📒 Files selected for processing (1)
  • packages/cli-v3/src/executions/taskRunProcess.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli-v3/src/executions/taskRunProcess.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

pkg-pr-new bot commented Oct 7, 2024

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/build@1387
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev@1387
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/core@1387
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/sdk@1387

commit: a3c6dc1

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

🧹 Outside diff range and nitpick comments (16)
packages/core/src/v3/links.ts (1)

1-17: LGTM! Consider using template literals for base URLs.

The links constant is well-structured and provides a centralized place for important URLs, which is great for maintainability. The use of HTTPS for all links is commendable from a security standpoint.

To further improve maintainability, consider using template literals for base URLs. This would make it easier to update the base URL if needed in the future. For example:

const BASE_DOCS_URL = "https://trigger.dev/docs";
const BASE_SITE_URL = "https://trigger.dev";

export const links = {
  docs: {
    config: {
      home: `${BASE_DOCS_URL}/config/config-file`,
      additionalPackages: `${BASE_DOCS_URL}/config/config-file#additionalpackages`,
      // ... other config links
    },
    machines: {
      home: `${BASE_DOCS_URL}/v3/machines`,
    },
  },
  site: {
    home: BASE_SITE_URL,
    contact: `${BASE_SITE_URL}/contact`,
  },
};

This approach would make it easier to update the base URL across all links if needed in the future.

packages/cli-v3/src/deploy/logs.ts (2)

49-51: Improved error message for Prisma schema issues

The updated error message for Prisma schema issues is more specific and helpful. The change from "Config docs" to "Extension docs" in the link text is appropriate, and the use of the links object is consistent with the new import structure.

Consider adding a brief explanation of what the Prisma extension is or why it's needed, to further assist users who might be unfamiliar with it.


63-69: Enhanced error message for missing package or binary

The updated error message for missing package or binary is a significant improvement. It now provides more specific guidance by differentiating between package-related and binary-related issues, with separate links to relevant documentation. This change aligns well with the PR objective of enhancing error handling and display.

Consider adding a brief explanation of how to determine if the missing item is a package or a binary, to help users choose the appropriate link to follow.

apps/webapp/app/v3/services/crashTaskRun.server.ts (3)

18-18: LGTM: Enhanced error handling with errorCode.

The addition of the optional errorCode property to CrashTaskRunServiceOptions allows for more specific error reporting, which aligns well with the PR objectives. This change enhances the flexibility of error handling in the CrashTaskRunService.

Consider adding a brief comment explaining the purpose of this new property, especially its relationship with TaskRunInternalError["code"], to improve code readability.


30-31: LGTM: Improved logging and flexible error code assignment.

The changes enhance the call method in two ways:

  1. The new debug log improves traceability, which is crucial for debugging complex systems.
  2. The use of opts.errorCode in the error object allows for more specific error reporting while maintaining backwards compatibility with the default "TASK_RUN_CRASHED" code.

These improvements align well with the PR objectives of enhancing error handling and reporting.

Consider using a template literal for the debug log message to improve readability:

logger.debug(`CrashTaskRunService.call: runId=${runId}`, { opts });

Also applies to: 77-77


153-153: LGTM: Consistent error code handling in error object creation.

The modification to use error.code (if provided) in the error object creation is consistent with the changes made in the call method. This allows for more specific error reporting when failing an attempt while maintaining backwards compatibility with the default "TASK_RUN_CRASHED" code.

Consider extracting the default error code "TASK_RUN_CRASHED" into a constant at the module level. This would improve maintainability and ensure consistency across the file. For example:

const DEFAULT_ERROR_CODE = "TASK_RUN_CRASHED";

// Then use it like this:
code: error.code ?? DEFAULT_ERROR_CODE,

This change would make it easier to update the default error code in the future if needed.

packages/core/src/v3/schemas/common.ts (1)

90-91: LGTM! Consider adding comments for clarity.

The new error codes (TASK_PROCESS_OOM_KILLED, TASK_PROCESS_MAYBE_OOM_KILLED, DISK_SPACE_EXCEEDED, POD_EVICTED, POD_UNKNOWN_ERROR) are well-aligned with the PR objectives of improving error handling. They cover important scenarios related to resource limitations and pod issues.

Consider adding brief comments for each new error code to explain their specific use cases. This would enhance code readability and maintainability. For example:

// Indicates that the task process was killed due to Out of Memory (OOM)
TASK_PROCESS_OOM_KILLED: "TASK_PROCESS_OOM_KILLED",
// Indicates that the task process was possibly killed due to Out of Memory (OOM)
TASK_PROCESS_MAYBE_OOM_KILLED: "TASK_PROCESS_MAYBE_OOM_KILLED",
// Indicates that the task exceeded the allocated disk space
DISK_SPACE_EXCEEDED: "DISK_SPACE_EXCEEDED",
// Indicates that the pod running the task was evicted
POD_EVICTED: "POD_EVICTED",
// Indicates an unknown error occurred with the pod running the task
POD_UNKNOWN_ERROR: "POD_UNKNOWN_ERROR",

Also applies to: 98-100

apps/webapp/app/v3/handleSocketIo.server.ts (1)

Line range hint 191-210: Overall improvement in error logging for CREATE_TASK_RUN_ATTEMPT

The changes made to the CREATE_TASK_RUN_ATTEMPT handler significantly enhance the error logging capabilities. By consistently providing more context in error logs, including handler names and full message objects, these improvements will greatly facilitate debugging and issue resolution. This aligns well with the PR objectives of enhancing error handling and display.

To further improve the code, consider the following suggestions:

  1. Standardize the error message format across all handlers in this file for consistency.
  2. Consider adding structured logging with error codes for easier parsing and analysis of logs.
  3. Implement a centralized error handling mechanism to ensure consistent error reporting across the application.

Would you like assistance in implementing any of these suggestions?

packages/core/src/v3/schemas/messages.ts (1)

Line range hint 371-374: Approve new CREATE_WORKER message version with suggestion

The introduction of a v2 version for the CREATE_WORKER message with the new supportsLazyAttempts boolean field is a good approach to extend functionality while maintaining backward compatibility. This change likely enables more efficient task execution or scheduling.

Consider adding a brief comment explaining the purpose and implications of the supportsLazyAttempts field for better maintainability.

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

Line range hint 404-1016: Overall improvement in error handling and logging

The changes made in this file consistently enhance error handling and logging across various parts of the TaskCoordinator class. Key improvements include:

  1. Addition of runId to error logs, improving traceability.
  2. More descriptive error messages, particularly for timeout scenarios.
  3. Inclusion of failure reasons in error logs for lazy attempts and attempt creations.

These enhancements align well with the PR objectives of improving error handling and display. They will significantly aid in debugging and understanding the context of errors when they occur. The consistent approach across different parts of the code is commendable and will make the system more maintainable.

One suggestion for further improvement:

Consider extracting the error logging logic into a separate function to reduce code duplication and ensure consistency. This could be implemented as follows:

private logError(context: string, error: any, additionalInfo: Record<string, any> = {}) {
  logger.error(`Error in ${context}`, {
    error,
    runId: this.runId,
    ...additionalInfo
  });
}

// Usage
this.logError("READY_FOR_LAZY_ATTEMPT", error, { reason: lazyAttempt.reason });

This refactoring would further improve code maintainability and ensure consistent error logging across the entire class.

apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts (3)

Line range hint 1163-1185: LGTM! Consider adding more context to error logs.

The changes to improve error logging in the getLazyAttemptPayload method are good. They provide more context when errors occur, which will help with debugging.

Consider adding more context to the error logs, such as including the environment.type when logging the "Environment not found" error. This could help identify if the issue is specific to certain environment types.

-      logger.error("getLazyAttemptPayload: Environment not found", { runId, envId });
+      logger.error("getLazyAttemptPayload: Environment not found", { runId, envId, envType: environment?.type });

Line range hint 1223-1235: LGTM! Consider adding error handling.

The new taskHeartbeat method is a good addition for maintaining the liveness of task run attempts.

Consider adding error handling for the marqs?.heartbeatMessage call. If this operation fails, it might be important to log the error or take appropriate action.

 async taskHeartbeat(attemptFriendlyId: string) {
   logger.debug("[SharedQueueConsumer] taskHeartbeat()", { id: attemptFriendlyId });

   const taskRunAttempt = await prisma.taskRunAttempt.findUnique({
     where: { friendlyId: attemptFriendlyId },
   });

   if (!taskRunAttempt) {
     return;
   }

-  await marqs?.heartbeatMessage(taskRunAttempt.taskRunId);
+  try {
+    await marqs?.heartbeatMessage(taskRunAttempt.taskRunId);
+  } catch (error) {
+    logger.error("[SharedQueueConsumer] Failed to send heartbeat", { 
+      id: attemptFriendlyId, 
+      runId: taskRunAttempt.taskRunId, 
+      error 
+    });
+  }
 }

Line range hint 1237-1241: LGTM! Consider adding error handling.

The new taskRunHeartbeat method is a good addition for maintaining the liveness of task runs.

Similar to the taskHeartbeat method, consider adding error handling for the marqs?.heartbeatMessage call.

 async taskRunHeartbeat(runId: string) {
   logger.debug("[SharedQueueConsumer] taskRunHeartbeat()", { runId });

-  await marqs?.heartbeatMessage(runId);
+  try {
+    await marqs?.heartbeatMessage(runId);
+  } catch (error) {
+    logger.error("[SharedQueueConsumer] Failed to send run heartbeat", { runId, error });
+  }
 }
apps/kubernetes-provider/src/taskMonitor.ts (1)

Line range hint 164-203: Consider handling unforeseen rawReason values in the switch statement

In the #onPodUpdated method, the switch statement addresses specific rawReason cases like "Error", "Evicted", and "OOMKilled". To improve robustness, consider adding a default case or logging mechanism for unexpected rawReason values. This will help identify and handle new or unanticipated error reasons in the future.

packages/core/src/v3/errors.ts (2)

315-334: Ensure all internal error codes are covered in prettyInternalErrors

The prettyInternalErrors object provides user-friendly messages for specific internal error codes. Review this mapping to ensure that all relevant TaskRunInternalError codes are included for consistent error messaging.

Consider adding comments or documentation to explain the context of each error code.


385-401: Align enhancement logic between error enhancers

The exceptionEventEnhancer function mirrors some logic from taskRunErrorEnhancer. Review both functions to ensure consistency in error enhancement and that any divergences are justified.

Extracting shared logic into a helper function might improve maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2c014f7 and 6e3dbd0.

📒 Files selected for processing (20)
  • .changeset/plenty-spoons-build.md (1 hunks)
  • apps/coordinator/src/index.ts (5 hunks)
  • apps/kubernetes-provider/src/taskMonitor.ts (4 hunks)
  • apps/webapp/app/components/runs/v3/RunInspector.tsx (2 hunks)
  • apps/webapp/app/components/runs/v3/SpanEvents.tsx (2 hunks)
  • apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam.spans.$spanParam/route.tsx (3 hunks)
  • apps/webapp/app/v3/handleSocketIo.server.ts (2 hunks)
  • apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts (2 hunks)
  • apps/webapp/app/v3/services/crashTaskRun.server.ts (6 hunks)
  • packages/cli-v3/src/deploy/logs.ts (3 hunks)
  • packages/cli-v3/src/dev/backgroundWorker.ts (3 hunks)
  • packages/cli-v3/src/entryPoints/deploy-run-controller.ts (1 hunks)
  • packages/cli-v3/src/executions/taskRunProcess.ts (3 hunks)
  • packages/cli-v3/src/utilities/deployErrors.ts (0 hunks)
  • packages/cli-v3/src/utilities/links.ts (0 hunks)
  • packages/core/src/v3/errors.ts (4 hunks)
  • packages/core/src/v3/index.ts (1 hunks)
  • packages/core/src/v3/links.ts (1 hunks)
  • packages/core/src/v3/schemas/common.ts (2 hunks)
  • packages/core/src/v3/schemas/messages.ts (2 hunks)
💤 Files with no reviewable changes (2)
  • packages/cli-v3/src/utilities/deployErrors.ts
  • packages/cli-v3/src/utilities/links.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/plenty-spoons-build.md
🧰 Additional context used
🔇 Additional comments (45)
packages/core/src/v3/index.ts (1)

20-20: LGTM! New export aligns with PR objectives.

The addition of export { links } from "./links.js"; is consistent with the file's structure and export patterns. This new export likely supports the PR's objective of enhancing error displays with links to relevant documentation, improving the user experience when encountering errors.

packages/cli-v3/src/deploy/logs.ts (4)

6-6: Improved link management with centralized import

The change from a local utility import to a package import from "@trigger.dev/core/v3" is a good improvement. It centralizes link management, which enhances maintainability and consistency across the project.


56-58: Consistent improvement in Prisma client initialization error message

The changes to the Prisma client initialization error message are consistent with the previous improvements. The updated link text and structure provide clear guidance to users, directing them to the relevant extension documentation.


104-107: Consistent improvement in Prisma schema warning message

The changes to the Prisma schema warning message are consistent with the previous improvements to error messages. The updated link text and structure provide clear guidance to users, directing them to the relevant extension documentation. This change maintains consistency throughout the file and aligns well with the PR objectives.


Line range hint 1-145: Overall improvements in error handling and messaging

The changes in this file significantly enhance the error handling and messaging system, aligning perfectly with the PR objectives. Key improvements include:

  1. Centralized link management through the new import from "@trigger.dev/core/v3".
  2. More specific and informative error and warning messages.
  3. Consistent use of "Extension docs" links throughout the file.
  4. Improved guidance for users encountering issues with Prisma or missing packages/binaries.

These changes will greatly improve the user experience by providing more helpful and targeted information when errors or warnings occur. The centralized link management also enhances the maintainability of the codebase.

apps/webapp/app/v3/services/crashTaskRun.server.ts (2)

8-8: LGTM: Necessary import for enhanced error handling.

The import of sanitizeError and TaskRunInternalError from "@trigger.dev/core/v3" is appropriate for the new error handling functionality introduced in this file.


135-135: LGTM: Consistent error code handling in #failAttempt.

The addition of the optional code property to the error parameter in the #failAttempt method signature is consistent with the changes made to the call method and CrashTaskRunServiceOptions. This change allows for more specific error reporting when failing an attempt, which aligns with the overall goal of improving error handling in the system.

packages/core/src/v3/schemas/common.ts (2)

115-116: LGTM! Consistent error code updates.

The new error codes have been correctly added to the TaskRunInternalError schema, maintaining consistency with the TaskRunErrorCodes object. This ensures that these new error types can be properly handled in internal error processing.

Also applies to: 124-126


90-91: Overall, these changes enhance error handling capabilities.

The additions to both TaskRunErrorCodes and TaskRunInternalError schemas significantly improve the system's ability to report and handle specific error scenarios, particularly those related to resource limitations (OOM, disk space) and pod issues. These enhancements align well with the PR's objective of improving error handling and reporting.

The new error codes provide more granular information about task execution failures, which can be crucial for debugging and maintaining the system. They also allow for more specific error messages to be presented to users, potentially improving the overall user experience when encountering these issues.

Also applies to: 98-100, 115-116, 124-126

apps/webapp/app/v3/handleSocketIo.server.ts (3)

191-191: Improved error logging for environment not found

The error logging has been enhanced to provide more context. By including the handler name "CREATE_TASK_RUN_ATTEMPT" and logging the entire message object, it will be easier to debug issues related to missing environments.


201-201: Enhanced error logging for payload retrieval failure

The error logging for payload retrieval failure has been improved. By logging the entire message object, it provides more comprehensive information for debugging purposes. This change aligns with the previous improvement and maintains consistency in error logging practices.


208-210: Comprehensive error logging for attempt creation failures

The error logging in the catch block has been significantly improved. By spreading the entire message object (...message) into the logged error, it now provides a complete context of the attempt creation process. This change will greatly enhance the ability to debug and troubleshoot issues related to attempt creation failures.

packages/core/src/v3/schemas/messages.ts (2)

8-8: LGTM: New import for TaskRunInternalError

The addition of TaskRunInternalError import from ./common.js is appropriate. This new type will likely be used to enhance error reporting in the message schemas.


256-256: Excellent addition of errorCode to WORKER_CRASHED message

The inclusion of an optional errorCode field in the WORKER_CRASHED message, using TaskRunInternalError.shape.code, is a valuable enhancement. This addition will provide more detailed and standardized error reporting when a worker crashes, aligning well with the PR's objective of improving error handling and display.

apps/coordinator/src/index.ts (6)

404-407: Improved error logging with runId

The addition of runId to the error log enhances traceability and aligns with the PR's objective of improving error handling. This change will make it easier to identify which specific run encountered an issue during the checkpoint readiness process.


410-413: Enhanced error message for checkpoint readiness timeout

The addition of a more descriptive error message for checkpoint readiness timeout improves the clarity of error reporting. It now includes the timeout duration and the reason for the checkpoint, which will aid in debugging and understanding the context of the error.


496-497: Consistent improvement in error logging

The addition of runId to the error log in the READY_FOR_EXECUTION error handler maintains consistency with the earlier improvements. This change enhances error traceability and aids in debugging by providing context about which run encountered an issue.


530-533: Detailed error logging for lazy attempt failures

The error logging for failed lazy attempt payloads has been improved to include both the runId and the reason for the failure. This enhancement provides more comprehensive information for debugging and aligns well with the PR's goal of improving error handling and reporting.


555-556: Consistent error logging improvement

The addition of runId to the error log in the READY_FOR_LAZY_ATTEMPT error handler maintains consistency with the earlier improvements. This change enhances error traceability and aids in debugging by providing context about which run encountered an issue during the lazy attempt process.


1013-1016: Improved error logging for attempt creation failures

The error logging for failed attempt creations has been enhanced to include both the runId and the reason for the failure. This improvement provides more comprehensive information for debugging and aligns well with the PR's goal of improving error handling and reporting. The consistent approach to error logging across different parts of the code is commendable.

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam.spans.$spanParam/route.tsx (4)

937-938: Enhancement: Improved error handling with taskRunErrorEnhancer

The addition of taskRunErrorEnhancer is a positive change that enhances the error handling capabilities of the component. This function likely provides more detailed and structured error information, improving the overall error reporting in the application.


939-944: Improved error display with enhanced error object

The switch statement now uses the enhancedError object, which provides more detailed error information. This change improves the error display by:

  1. Handling different error types more effectively.
  2. Displaying more specific error details (e.g., name, message, stack trace).
  3. Potentially providing links to documentation for certain errors.

These improvements will help developers and users better understand and debug issues.

Also applies to: 953-953, 961-961, 965-971, 975-975


965-971: New feature: Added documentation link for certain errors

The addition of a conditional rendering for enhancedError.link is a great improvement. It provides users with quick access to relevant documentation when available, which can help in troubleshooting and understanding the error context.


Line range hint 937-975: Overall improvement in error handling and display

The changes to the RunError component significantly enhance the error reporting capabilities of the application. By using the taskRunErrorEnhancer and providing more detailed error information, including potential documentation links, the modifications align well with the PR objectives of creating prettier errors and related improvements.

These enhancements will lead to:

  1. More informative error messages for users and developers.
  2. Easier troubleshooting with access to relevant documentation.
  3. Better categorization and display of different error types.

Great job on improving the error handling system!

apps/webapp/app/components/runs/v3/SpanEvents.tsx (6)

2-3: New utility functions are correctly imported.

The exceptionEventEnhancer and isExceptionSpanEvent functions are appropriately imported from @trigger.dev/core/v3, ensuring they are available for use in the component.


68-69: Enhancing exceptions for improved error handling.

Using exceptionEventEnhancer to create an enhancedException allows for enriched exception data, which enhances the error display and provides more detailed information to the user.


73-73: Displaying the enhanced exception type in the header.

Updating the title prop to use enhancedException.type ensures that the more specific error type is displayed, improving clarity in the error presentation.


77-77: Conditionally rendering the enhanced exception message.

The check {enhancedException.message && ...} correctly ensures that the error message is displayed only when available, enhancing the user experience by preventing empty or undefined messages.


78-82: Providing helpful documentation links for exceptions.

Including a conditional rendering of a Callout with enhancedException.link offers users direct access to relevant documentation, aiding in quicker resolution of errors.


83-87: Displaying the enhanced exception stack trace.

Rendering enhancedException.stacktrace within a CodeBlock provides detailed debugging information, which is valuable for developers when troubleshooting issues.

apps/kubernetes-provider/src/taskMonitor.ts (1)

6-13: Enhance error reporting with errorCode in FailureDetails

The addition of the errorCode property to the FailureDetails type and the corresponding import statement improves error categorization and provides more granular error reporting. This enhancement will aid in better troubleshooting and handling of pod failures.

packages/cli-v3/src/dev/backgroundWorker.ts (4)

16-16: Importing SigKillTimeoutProcessError for proper error handling

The addition of the import statement for SigKillTimeoutProcessError is necessary for throwing this specific error in the #tryForcefulExit method. This ensures that timeouts during forced process termination are correctly handled and reported.


486-486: Utilizing #correctError method to standardize error correction

By calling await this.#correctError(error), the error handling logic is centralized, promoting consistency and maintainability in how errors are corrected within the class.


500-500: Parsing exceptions with TaskRunProcess.parseExecuteError

Using TaskRunProcess.parseExecuteError(e) in the catch block ensures that exceptions are consistently parsed into a standardized error format. This improves the robustness of error reporting.


505-507: Simplifying #correctError method signature

The #correctError method signature has been updated to remove the unnecessary execution parameter, now requiring only the error argument. This simplification streamlines the method's usage. All internal calls to this method have been updated accordingly.

packages/core/src/v3/errors.ts (4)

4-9: Imports are appropriate and necessary

The additional imports of SerializedError, TaskRunError, TaskRunErrorCodes, TaskRunInternalError, links, and ExceptionEventProperties are correctly added to support the new error handling enhancements.

Also applies to: 11-12


78-79: Ensure enhanced errors are correctly processed

The introduction of const enhancedError = taskRunErrorEnhancer(error); enhances the error before serialization. Verify that all possible TaskRunError types are handled correctly within taskRunErrorEnhancer to prevent unexpected issues during error processing.

Consider adding unit tests to ensure comprehensive coverage of all error types.


340-383: Verify comprehensive handling in taskRunErrorEnhancer

The taskRunErrorEnhancer function enhances errors based on their type and specific conditions. Ensure that all edge cases are considered, and that the function correctly enhances or defaults errors as intended.

Adding unit tests for different error scenarios can help confirm the enhancer's reliability.


403-433: Clarify logic in internalErrorFromUnexpectedExit

The function internalErrorFromUnexpectedExit maps unexpected exit errors to internal error codes. Verify that the conditions accurately reflect the possible exit scenarios, especially regarding the dockerMode flag.

Consider adding explanatory comments to clarify why certain exit codes correspond to specific internal errors.

apps/webapp/app/components/runs/v3/RunInspector.tsx (6)

3-8: Added imports are appropriate and necessary

The newly imported modules from @trigger.dev/core/v3 (formatDuration, formatDurationMilliseconds, TaskRunError, taskRunErrorEnhancer) are correctly added and are utilized in the code for enhanced error handling and duration formatting.


561-563: Proper usage of taskRunErrorEnhancer to enhance error objects

Enhancing the error object using taskRunErrorEnhancer before processing ensures that error handling accommodates different error types effectively.


571-571: Correct use of enhancedError.raw in error display

Displaying enhancedError.raw within the CodeBlock component for STRING_ERROR and CUSTOM_ERROR types appropriately shows the raw error content to the user.


579-579: Conditional retrieval of error name or code is appropriate

The logic to retrieve the error title using enhancedError.name or enhancedError.code ensures that the correct identifier is displayed based on the available properties of the error object.


583-589: Conditional rendering of error details prevents potential issues

The code correctly checks for the presence of message, link, and stackTrace in enhancedError before rendering them. This approach avoids runtime errors and ensures that only available information is displayed to the user.


593-593: Displaying enhancedError.stackTrace enhances debugging

Including the stack trace in the error display aids in debugging by providing detailed context when enhancedError.stackTrace is available.

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.

1 participant