Skip to content

Fix "no tasks defined" issue (fix #1681) #1663

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 1 commit into from
Feb 4, 2025
Merged

Fix "no tasks defined" issue (fix #1681) #1663

merged 1 commit into from
Feb 4, 2025

Conversation

ericallam
Copy link
Member

@ericallam ericallam commented Feb 4, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new sample task that outputs a greeting to help demonstrate task functionality.
    • Expanded configuration options to include additional directories for smoother source file detection.
  • Bug Fixes

    • Resolved misconfigurations that led to missing task errors.
    • Improved error reporting with clearer, more actionable messages during development.
  • Chores

    • Upgraded key dependencies to boost stability and performance.

Copy link

changeset-bot bot commented Feb 4, 2025

🦋 Changeset detected

Latest commit: 79e8c72

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

This PR includes changesets to release 12 packages
Name Type
trigger.dev Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@internal/redis-worker Patch
@internal/zod-worker Patch
references-nextjs-realtime Patch
@internal/testcontainers 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 Feb 4, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/cli-v3/src/build/entryPoints.ts

Oops! Something went wrong! :(

ESLint: 8.45.0

ESLint couldn't find the config "custom" to extend from. Please check that the name of the config is correct.

The config "custom" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

references/v3-catalog/trigger.config.ts

Oops! Something went wrong! :(

ESLint: 8.45.0

ESLint couldn't find the config "custom" to extend from. Please check that the name of the config is correct.

The config "custom" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

packages/cli-v3/src/dev/workerRuntime.ts

Oops! Something went wrong! :(

ESLint: 8.45.0

ESLint couldn't find the config "custom" to extend from. Please check that the name of the config is correct.

The config "custom" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

  • 2 others

Walkthrough

This pull request updates multiple components of the project. It fixes the misconfigured directory search issue for trigger.dev by patching configuration and improving error handling in the bundling process. A dependency upgrade for tinyglobby is included. The entry point manager now returns additional pattern properties for improved matching and logging. Worker manifest validation has been refined with structured error output using helper functions. Additionally, a new helloWorld task is added to the catalog and the trigger configuration is updated with new directories.

Changes

File(s) Change Summary
.changeset/eleven-eels-draw.md
references/v3-catalog/trigger.config.ts
Added patch for trigger.dev configuration and updated config with new dirs property
packages/cli-v3/package.json Upgraded tinyglobby dependency from ^0.2.2 to ^0.2.10
packages/cli-v3/src/build/bundle.ts
packages/cli-v3/src/build/entryPoints.ts
Enhanced entry point detection with new error handling, additional logging, updated types, and new imports to support error messaging
packages/cli-v3/src/dev/workerRuntime.ts Refined worker manifest validation: changed return type to a structured ValidationIssue, added helper functions to format error outputs
references/v3-catalog/src/trigger2/helloWorld.ts Introduced a new helloWorld task with an asynchronous run method that logs "Hello World!"

Sequence Diagram(s)

sequenceDiagram
    participant U as User/System
    participant BW as bundleWorker
    participant EPM as EntryPointManager
    participant PE as prettyError

    U->>BW: Invoke bundling process
    BW->>EPM: Retrieve entry points
    EPM-->>BW: Return entry points (possibly empty)
    alt No entry points found
        BW->>PE: Log detailed error message (with config & help link)
        BW->>BW: Throw SkipLoggingError to halt bundling
    else Entry points exist
        BW->>BW: Proceed with bundling
    end
Loading
sequenceDiagram
    participant Dev as Developer
    participant VM as validateWorkerManifest
    participant HF as HelperFunctions
    participant PE as prettyError

    Dev->>VM: Provide WorkerManifest
    VM->>VM: Validate tasks (check duplicates, no tasks defined)
    alt Validation issue found
        VM->>HF: Generate header, message, footer
        HF-->>VM: Return formatted error details
        VM->>PE: Log formatted error details
        VM-->>Dev: Return structured ValidationIssue
    else No issues
        VM-->>Dev: Return undefined
    end
Loading

Poem

In a burrow of code so neat,
I hop through patches with happy feet.
I fix the bugs, smooth out the flow,
With clearer logs and patterns to show.
Code blossoms like a springtime treat—
A bunny’s cheer in each byte we meet! 🐇✨

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

🧹 Nitpick comments (6)
references/v3-catalog/src/trigger2/helloWorld.ts (1)

3-8: Enhance task implementation for production readiness.

The task implementation could be improved with proper logging and error handling.

 const helloWorld = task({
   id: "helloWorld",
   async run() {
-    console.log("Hello World!");
+    try {
+      logger.info("Starting helloWorld task");
+      // Add your task logic here
+      logger.info("Successfully completed helloWorld task");
+    } catch (error) {
+      logger.error("Error in helloWorld task", { error });
+      throw error;
+    }
   },
 });
packages/cli-v3/src/build/entryPoints.ts (2)

39-45: Consider making pattern generation more flexible.

The pattern generation could be enhanced to support more file extensions and custom patterns.

 const patterns = dirs.flatMap((dir) => [
   `${
     isDynamicPattern(dir)
-      ? `${dir}/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}`
-      : `${escapePath(dir)}/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}`
+      ? `${dir}/*.{${config.fileExtensions ?? 'ts,tsx,mts,cts,js,jsx,mjs,cjs'}}`
+      : `${escapePath(dir)}/**/*.{${config.fileExtensions ?? 'ts,tsx,mts,cts,js,jsx,mjs,cjs'}}`
   }`,
 ]);

48-54: Make ignore patterns configurable through config.

Consider allowing users to customize additional ignore patterns through configuration.

-let ignorePatterns = config.ignorePatterns ?? DEFAULT_IGNORE_PATTERNS;
-ignorePatterns = ignorePatterns.concat([
+const defaultSystemIgnores = [
   "**/node_modules/**",
   "**/.git/**",
   "**/.trigger/**",
   "**/.next/**",
-]);
+];
+let ignorePatterns = [
+  ...(config.ignorePatterns ?? DEFAULT_IGNORE_PATTERNS),
+  ...(config.additionalIgnorePatterns ?? []),
+  ...defaultSystemIgnores,
+];
packages/cli-v3/src/build/bundle.ts (1)

76-97: Enhance error message with more context.

The error message could be more helpful by including:

  • The current working directory
  • The ignored patterns that might be filtering out files
  • More specific troubleshooting steps based on the configuration
 if (entryPointManager.entryPoints.length === 0) {
   const errorMessageBody = `
+    Working directory: ${resolvedConfig.workingDir}
+
     Dirs config:
     ${resolvedConfig.dirs.join("\n- ")}

     Search patterns: 
     ${entryPointManager.patterns.join("\n- ")}

+    Ignored patterns:
+    ${entryPointManager.ignorePatterns.join("\n- ")}
+
     Possible solutions:
     1. Check if the directory paths in your config are correct
     2. Verify that your files match the search patterns
     3. Update the search patterns in your config
+    4. Check if your files are being excluded by ignore patterns
+    5. Ensure you're running the command from the correct directory
   `.replace(/^ {6}/gm, "");

   prettyError(
-    "No trigger files found",
+    "No trigger files found in specified directories",
     errorMessageBody,
     cliLink("View the config docs", "https://trigger.dev/docs/config/config-file")
   );

   throw new SkipLoggingError();
 }
packages/cli-v3/src/dev/workerRuntime.ts (1)

369-385: Consider adding early returns for better readability.

The function can be simplified by removing the unused issues array and using early returns.

 function validateWorkerManifest(manifest: WorkerManifest): ValidationIssue | undefined {
-  const issues: ValidationIssue[] = [];
-
   if (!manifest.tasks || manifest.tasks.length === 0) {
     return { type: "noTasksDefined" };
   }

   // Check for any duplicate task ids
   const taskIds = manifest.tasks.map((task) => task.id);
   const duplicateTaskIds = taskIds.filter((id, index) => taskIds.indexOf(id) !== index);

   if (duplicateTaskIds.length > 0) {
     return { type: "duplicateTaskId", duplicationTaskIds: duplicateTaskIds };
   }

   return undefined;
 }
.changeset/eleven-eels-draw.md (1)

1-6: Fix grammatical issue in the description.

The phrase "during in dev" is redundant.

-Fix "No tasks defined" issue because of misconfigured dir search paths. Also improve errors around no files or no tasks found during in dev"
+Fix "No tasks defined" issue because of misconfigured dir search paths. Also improve errors around no files or no tasks found during dev"
🧰 Tools
🪛 LanguageTool

[style] ~5-~5: This phrase is redundant. Consider writing “during” or “in”.
Context: ...rrors around no files or no tasks found during in dev"

(DURING_IN)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e615736 and 79e8c72.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .changeset/eleven-eels-draw.md (1 hunks)
  • packages/cli-v3/package.json (1 hunks)
  • packages/cli-v3/src/build/bundle.ts (2 hunks)
  • packages/cli-v3/src/build/entryPoints.ts (5 hunks)
  • packages/cli-v3/src/dev/workerRuntime.ts (3 hunks)
  • references/v3-catalog/src/trigger2/helloWorld.ts (1 hunks)
  • references/v3-catalog/trigger.config.ts (1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/eleven-eels-draw.md

[style] ~5-~5: This phrase is redundant. Consider writing “during” or “in”.
Context: ...rrors around no files or no tasks found during in dev"

(DURING_IN)

⏰ 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: typecheck / typecheck
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
packages/cli-v3/src/dev/workerRuntime.ts (2)

360-367: LGTM! Well-structured validation issue type.

The new ValidationIssue type provides clear categorization of validation issues, making it easier to handle and display appropriate error messages.


409-444: Great error messaging with example code!

The error message for "noTasksDefined" is particularly helpful as it includes:

  1. List of files being processed
  2. Clear explanation of the issue
  3. Example code showing how to fix it
packages/cli-v3/package.json (1)

123-123: Verify the tinyglobby version update.

The update from ^0.2.2 to ^0.2.10 is a minor version bump. Let's verify if there are any breaking changes or important updates in this version.

✅ Verification successful

Tinyglobby version bump verified: No breaking changes detected.
Based on the available changelog data, the update from ^0.2.2 to ^0.2.10 involves only minor improvements—such as relicensing to MIT, disabling source maps for smaller bundles, and refining the common root inference algorithm—with no breaking changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Web query:

What are the changes between tinyglobby v0.2.2 and v0.2.10?

Length of output: 4019

Copy link

pkg-pr-new bot commented Feb 4, 2025

@trigger.dev/build

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/build@1663

trigger.dev

npm i https://pkg.pr.new/triggerdotdev/trigger.dev@1663

@trigger.dev/react-hooks

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/react-hooks@1663

@trigger.dev/rsc

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/rsc@1663

@trigger.dev/core

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/core@1663

@trigger.dev/sdk

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/sdk@1663

commit: 79e8c72

@ericallam ericallam merged commit 3887c4a into main Feb 4, 2025
13 checks passed
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