Skip to content
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

fix: use @eggjs/onerror #5389

Merged
merged 4 commits into from
Feb 3, 2025
Merged

fix: use @eggjs/onerror #5389

merged 4 commits into from
Feb 3, 2025

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Feb 2, 2025

Summary by CodeRabbit

  • Chores
    • Updated dependency versions and plugin configurations for enhanced system stability and compatibility.
  • Documentation
    • Revised guides across multi-process handling, session management, error handling, and Socket.IO with corrected links and updated package names.
  • Refactor
    • Modernized asynchronous patterns and restructured lifecycle methods for better reliability.
  • New Features
    • Enhanced framework communication by introducing improved messaging capabilities.
    • Introduced a new read-only property for better access to messaging functionalities.

@fengmk2 fengmk2 added this to the 4.0 milestone Feb 2, 2025
Copy link

coderabbitai bot commented Feb 2, 2025

Walkthrough

This pull request updates various aspects of the Egg framework. It removes a deprecated import from type definitions and revises package dependencies and documentation references to align with the updated naming (e.g., changing egg-onerror to @eggjs/onerror). The documentation now details an improved multi-process (Leader/Follower) client model and corrects outdated URLs and package names. Additionally, the core code and test suites have been refactored for enhanced type safety, asynchronous handling, and modular initialization via a new class-based Boot implementation.

Changes

Files Change Summary
index-old.d.ts, src/lib/types.ts, src/config/plugin.ts, site/docs/core/error-handling*.md, test/lib/core/loader/load_plugin.test.ts Removed or updated references to egg-onerror, switching to @eggjs/onerror (import removals, package property changes, and assertion updates).
package.json Updated dependency and devDependency versions; added new dependency @eggjs/onerror.
site/docs/advanced/cluster-client*.md, site/docs/basics/plugin*.md, site/docs/core/cookie-and-session*.md, site/docs/tutorials/socketio*.md Revised documentation to update package references (e.g., egg-redis to @eggjs/redis) and detail a new multi-process client model with a Leader/Follower pattern.
src/lib/egg.ts Added a new read-only property messenger to the EggCore interface.
Test files (e.g., test/cluster1/cluster-client.test.ts, test/fixtures/apps/cluster_mod_app/agent.js, test/index.test-d.ts, test/lib/core/messenger/local.test.ts, test/utils.ts) Refactored tests to use async/await, updated type expectations and conversions, introduced the SingleModeApplication interface, and restructured agent initialization via a new Boot class.

Sequence Diagram(s)

sequenceDiagram
    participant Leader
    participant Follower
    participant RemoteServer

    Note over Leader, Follower: Leader/Follower Communication Model
    Leader->>RemoteServer: Establish socket connection
    Follower->>Leader: Send operation request
    Leader->>RemoteServer: Process request
    RemoteServer-->>Leader: Return response
    Leader-->>Follower: Forward response
Loading
sequenceDiagram
    participant Agent
    participant Boot

    Agent->>Boot: Instantiate Boot class
    Boot->>Boot: didLoad() - initialize clients
    Boot->>Boot: willReady() - verify readiness
    Boot-->>Agent: Signal boot completion
Loading

Possibly related PRs

Suggested labels

plugin: egg-security, plugin: egg-session

Poem

I'm a rabbit in the codey wood,
Hopping through changes, feeling good.
Imports removed and docs refined,
A Leader/Follower model now defined.
With tests and types in perfect tune,
I celebrate these changes under a coding moon.
🐇 Happy hops to all in this new afternoon!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e6e793b and 9ebbea3.

📒 Files selected for processing (2)
  • src/lib/egg.ts (1 hunks)
  • test/index.test-d.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/lib/egg.ts
  • test/index.test-d.ts
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Node.js / Test (windows-latest, 18)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18)
  • GitHub Check: Node.js / Test (windows-latest, 18)
  • GitHub Check: Node.js / Test (windows-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18)
  • GitHub Check: Node.js / Test (windows-latest, 22)
  • GitHub Check: Node.js / Test (windows-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 18)
  • GitHub Check: Node.js / Test (ubuntu-latest, 22)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18)
  • GitHub Check: Node.js / Test (macos-latest, 22)
  • GitHub Check: Node.js / Test (macos-latest, 18)
  • GitHub Check: Node.js / Test (macos-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 22)
  • GitHub Check: Node.js / Test (windows-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 22)

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

codecov bot commented Feb 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.94%. Comparing base (5d15623) to head (9ebbea3).
Report is 2 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #5389   +/-   ##
=======================================
  Coverage   94.94%   94.94%           
=======================================
  Files          40       40           
  Lines        3739     3741    +2     
  Branches      354      354           
=======================================
+ Hits         3550     3552    +2     
  Misses        189      189           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

🔭 Outside diff range comments (2)
site/docs/advanced/cluster-client.md (2)

437-437: Syntax Error in APIClient Instantiation Example
There is a missing closing parenthesis in the example code snippet for instantiating APIClient (line 437). This can confuse readers copying the sample code.

Suggested fix:

-  app.apiClient = new APIClient(Object.assign({}, config, { cluster: app.cluster });
+  app.apiClient = new APIClient(Object.assign({}, config, { cluster: app.cluster }));

320-321: Variable Mismatch in MockClient’s sub Method
Within the sub(info, listener) method, the code incorrectly references reg.dataId instead of using the provided parameter name info.

Suggested fix:

-    const key = reg.dataId;
+    const key = info.dataId;
🧹 Nitpick comments (5)
test/fixtures/apps/cluster_mod_app/agent.js (2)

10-19: Consider adding error handling for client initialization.

If agent.cluster(...) or any client constructor fails, the code will not propagate exceptions gracefully. Wrapping these calls in a try/catch block can provide more visibility and prevent unhandled rejections.


21-26: Optimize readiness with concurrency.

Currently, readiness checks run sequentially. You can shorten startup time by awaiting them in parallel, for example:

-    await agent.registryClient.ready();
-    await agent.apiClient.ready();
-    await agent.apiClient2.ready();
+    await Promise.all([
+      agent.registryClient.ready(),
+      agent.apiClient.ready(),
+      agent.apiClient2.ready(),
+    ]);
test/fixtures/apps/cluster_mod_app/lib/registry_client.js (2)

1-2: Check for Node.js version compatibility.

Using url.parse() is fine for older Node.js versions. However, for modern Node.js (v10+), the URL constructor is generally recommended. Confirm that you need backward compatibility before favoring url.parse() over the URL class.


46-46: Consider the modern URL constructor for clarity and maintainability.

Replacing parse(url, true) with new URL(url) can improve code readability and align with current Node.js best practices. For instance:

- this.emit(key, this._registered.get(key).map(url => parse(url, true)));
+ this.emit(key, this._registered.get(key).map(urlString => new URL(urlString)));
site/docs/advanced/cluster-client.zh-CN.md (1)

556-557: Final APIClient Export Formatting
Minor formatting adjustments and a trailing newline change have been observed at the end of the file. No functional impact is detected; however, ensure adherence to the project’s code style guidelines.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b8d2d9d and e6e793b.

📒 Files selected for processing (22)
  • index-old.d.ts (0 hunks)
  • package.json (2 hunks)
  • site/docs/advanced/cluster-client.md (3 hunks)
  • site/docs/advanced/cluster-client.zh-CN.md (4 hunks)
  • site/docs/basics/plugin.md (1 hunks)
  • site/docs/basics/plugin.zh-CN.md (1 hunks)
  • site/docs/core/cookie-and-session.md (2 hunks)
  • site/docs/core/cookie-and-session.zh-CN.md (1 hunks)
  • site/docs/core/error-handling.md (1 hunks)
  • site/docs/core/error-handling.zh-CN.md (1 hunks)
  • site/docs/tutorials/socketio.md (1 hunks)
  • site/docs/tutorials/socketio.zh-CN.md (1 hunks)
  • src/config/plugin.ts (1 hunks)
  • src/lib/egg.ts (1 hunks)
  • src/lib/types.ts (1 hunks)
  • test/cluster1/cluster-client.test.ts (3 hunks)
  • test/fixtures/apps/cluster_mod_app/agent.js (1 hunks)
  • test/fixtures/apps/cluster_mod_app/lib/registry_client.js (2 hunks)
  • test/index.test-d.ts (3 hunks)
  • test/lib/core/loader/load_plugin.test.ts (1 hunks)
  • test/lib/core/messenger/local.test.ts (4 hunks)
  • test/utils.ts (3 hunks)
💤 Files with no reviewable changes (1)
  • index-old.d.ts
✅ Files skipped from review due to trivial changes (4)
  • site/docs/basics/plugin.zh-CN.md
  • site/docs/basics/plugin.md
  • site/docs/core/error-handling.md
  • site/docs/tutorials/socketio.md
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: Node.js / Test (ubuntu-latest, 22)
  • GitHub Check: Node.js / Test (windows-latest, 18)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18)
  • GitHub Check: Node.js / Test (macos-latest, 20)
  • GitHub Check: Node.js / Test (macos-latest, 22)
  • GitHub Check: Node.js / Test (macos-latest, 18)
  • GitHub Check: Node.js / Test (windows-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 18)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18)
  • GitHub Check: Node.js / Test (windows-latest, 18)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 22)
  • GitHub Check: Node.js / Test (ubuntu-latest, 22)
🔇 Additional comments (32)
test/fixtures/apps/cluster_mod_app/agent.js (1)

5-8: Clean class-based approach.

Exporting a class constructor is a clear and maintainable approach. Storing the agent instance in this.agent is straightforward and sets a good foundation for lifecycle methods.

src/config/plugin.ts (1)

9-9: Verify the new package installation for @eggjs/onerror.

Great switch to @eggjs/onerror. Ensure the dependency is declared in your project and that you aren’t missing any required migrations. You can run this script to verify its presence and version:

✅ Verification successful

@eggjs/onerror dependency verification succeeded

  • The repository’s root package.json declares "@eggjs/onerror": "^3.0.0".
  • No references to the old egg-onerror package were found in any package.json.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that @eggjs/onerror is listed in package.json with a valid version
rg '@eggjs/onerror' package.json

# Optionally, check for any references to the old egg-onerror package
rg 'egg-onerror' package.json

Length of output: 168


Script:

#!/bin/bash
echo "Searching for package.json files in the repository..."
fd package.json

echo ""
echo "Verifying @eggjs/onerror dependency in discovered package.json files:"
for file in $(fd package.json); do
  echo "----- Checking $file -----"
  rg '@eggjs/onerror' "$file"
  echo ""
  echo "----- Checking for any mentions of egg-onerror in $file -----"
  rg 'egg-onerror' "$file"
  echo ""
done

Length of output: 96173

test/cluster1/cluster-client.test.ts (3)

2-2: LGTM! Using node:timers/promises for better async handling.

The import of scheduler from node:timers/promises is a good choice for handling delays in tests, replacing the callback-based setTimeout.


19-19: LGTM! Using assert.equal for better error messages.

The change to use assert.equal instead of direct comparison improves error messages when assertions fail.

Also applies to: 59-59


23-34: LGTM! Improved test readability with async/await.

The refactoring to use async/await syntax makes the test cases more readable and maintainable by:

  • Eliminating promise chaining
  • Making the flow of asynchronous operations clearer
  • Using scheduler.wait(500) for delays

Also applies to: 63-74, 76-81, 83-88

test/utils.ts (2)

16-16: LGTM! Enhanced type safety for single process mode.

The addition of SingleModeApplication interface properly types the agent property, improving type safety and developer experience.

Also applies to: 28-30


62-62: LGTM! Improved return type accuracy.

The return type update to Promise<SingleModeApplication> ensures type consistency and better reflects the actual return value.

Also applies to: 70-70

test/index.test-d.ts (3)

13-13: LGTM! Added type checks for messenger interface.

The addition of IMessenger type checks ensures the messenger implementation maintains its contract.

Also applies to: 16-17


65-67: LGTM! Added type checks for onerror config.

The type checks for onerror config properties ensure type safety for error handling configuration.


113-114: LGTM! Improved AppBoot instantiation clarity.

Using a separate variable app1 for AppBoot instantiation improves code clarity and type safety.

test/lib/core/messenger/local.test.ts (3)

4-4: LGTM! Enhanced type safety with SingleModeApplication.

The update to use SingleModeApplication type improves type safety and consistency.

Also applies to: 7-7


147-148: LGTM! Maintained backward compatibility.

The type casting and comments explain the compatibility handling for process.pid usage.

Also applies to: 151-151


205-205: LGTM! Appropriate type casting for onMessage.

The type casting for onMessage call maintains compatibility while improving type safety.

src/lib/types.ts (1)

28-28: LGTM! Import added for @eggjs/onerror plugin types.

The import is correctly placed alongside other plugin type imports.

test/lib/core/loader/load_plugin.test.ts (1)

57-59: LGTM! Test assertions updated for @eggjs/onerror.

The test correctly verifies:

  1. The new ESM distribution path
  2. The updated package name
src/lib/egg.ts (1)

699-699: Verify the relationship with onerror migration.

While the addition of the messenger property is technically correct, it seems unrelated to the PR's objective of migrating to @eggjs/onerror. Please clarify if this change is necessary for the migration.

site/docs/core/error-handling.zh-CN.md (1)

62-62: LGTM! Documentation updated to reference @eggjs/onerror.

The documentation correctly reflects the new package name while maintaining the link to the GitHub repository.

package.json (2)

21-53: Dependency Updates in the Dependencies Block
The dependency versions have been updated across many packages (e.g. @eggjs/cluster, @eggjs/cookies, @eggjs/core, etc.), and the new dependency @eggjs/onerror has been added. Please ensure all these bump‐versions have been verified for compatibility with your framework’s internals and integration tests.


54-87: Updated DevDependencies
The devDependencies have been updated (e.g. @arethetypeswrong/cli, @eggjs/bin, mm, prettier, sdk-base, etc.) to reflect the latest versions. Double-check that these changes work seamlessly with your build and test workflow.

site/docs/core/cookie-and-session.zh-CN.md (3)

186-188: Updated Redis Session Plugin Description
The descriptive text now references the updated plugin packages—@eggjs/redis and @eggjs/session-redis—which aligns with the new naming conventions. This clarification will help users correctly configure external session storage.


189-197: Plugin Configuration Block Update
The code block defining the plugin configuration has been updated to use the new package names. Verify that the installation scripts and runtime configurations are consistent with these changes.


286-287: Updated Reference Links
The markdown reference links for @eggjs/redis and @eggjs/session-redis have been updated to point directly to their GitHub repositories. This improves clarity and ensures users follow the correct documentation paths.

site/docs/core/cookie-and-session.md (1)

1-120: No Significant Content Changes Detected
The English documentation appears to be consistent with the updated dependency naming conventions. It is recommended to verify that all package references in the text match the current configuration in package.json and related files.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~43-~43: Loose punctuation mark.
Context: ...rmission of Cookie. - {Number} maxAge: set the lifetime of the cookie in milli...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~44-~44: Loose punctuation mark.
Context: ...r specified lifetime. - {Date} expires: set the expiration time of the cookie. ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~45-~45: Loose punctuation mark.
Context: ...he time client closed. - {String} path: set the path of the cookie. By default ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~45-~45: Did you mean: “By default,”?
Context: ...ing} path: set the path of the cookie. By default it's on root path (/`), which means al...

(BY_DEFAULT_COMMA)


[uncategorized] ~46-~46: Loose punctuation mark.
Context: ...ccess to the cookie. - {String} domain: set the domain of the cookie. By defaul...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~47-~47: Loose punctuation mark.
Context: ...ss to the cookie. - {Boolean} httpOnly: set whether the cookie can be accessed ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~47-~47: Did you mean: “By default,”?
Context: ...e cookie can be accessed by Javascript. By default it's true, which means Javascript can...

(BY_DEFAULT_COMMA)


[uncategorized] ~48-~48: Loose punctuation mark.
Context: ... access the cookie. - {Boolean} secure: set whether the cookie can only be acce...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~48-~48: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ...e-secure-flag-work) for details. Egg.js auto sets this value to true if the current reque...

(AUTO_HYPHEN)


[uncategorized] ~52-~52: Loose punctuation mark.
Context: ...ore parameters: - {Boolean} overwrite: set the way of handling same Cookie key...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~53-~53: Loose punctuation mark.
Context: ... with the same key. - {Boolean} signed: set whether the cookie should be signed...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~53-~53: Did you mean: “By default,”?
Context: ...event cookie values modified by client. By default it's true. - {Boolean} encrypt: set w...

(BY_DEFAULT_COMMA)


[uncategorized] ~54-~54: Loose punctuation mark.
Context: ...default it's true. - {Boolean} encrypt: set whether the cookie should be encryp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~54-~54: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...l be encrypted before sending to clients so user clients cannot get raw text of the...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~54-~54: Did you mean: “By default,”?
Context: ...ents cannot get raw text of the cookie. By default it's false. When using Cookie, we need...

(BY_DEFAULT_COMMA)


[typographical] ~57-~57: Except for inverted sentences, ‘can it’ requires a question mark at the end of the sentence.
Context: ...ssed by JS, can it be modified by client. **By default, Cookie is signed but not...

(MD_PRP_QUESTION_MARK)


[style] ~62-~62: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...annot modify it (manually).** - If you need to allow JS to access and modify Cookie: ...

(REP_NEED_TO_VB)


[style] ~93-~93: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...e could have been modified by client. - If encrypt is true when set Cookie but...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~94-~94: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...d text rather than the raw plain text. If you want to get the cookie set by front...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~120-~120: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...g.js iterates through all keys. If you need to update Cookie secret key and don't want...

(REP_NEED_TO_VB)

site/docs/tutorials/socketio.zh-CN.md (1)

86-88: Clarification on Redis Configuration Separation
The note now explicitly states that when using @eggjs/redis in a project, separate configurations must be provided and they cannot be shared. This added clarity helps prevent misconfiguration in clustered environments.

site/docs/advanced/cluster-client.zh-CN.md (5)

8-19: Added Diagram for Multi-Process Communication
A new diagram (in a bash code block) illustrates how long connections are managed between clients and servers in a multi-process architecture. This visual aid provides a clear depiction of the Leader/Follower setup.


72-73: Refactored Import in Client Example
The client example now imports Base from sdk-base using destructuring (i.e. const { Base } = require('sdk-base');). This modernizes the code style and improves clarity regarding the required module’s interface.


168-169: Enhanced Module Import for URL Parsing
The RegistryClient example now uses the built-in Node.js URL parser via destructuring (i.e. const { parse } = require('node:url');). This is a best practice that improves readability and leverages current Node.js capabilities.


235-237: Improved Publish Method with URL Parsing
Within the publish method, mapping over the registered URLs now uses the parse function to ensure correct URL formatting. This change reinforces type safety for the published data.


456-484: APIClient Base Implementation Update
The APIClient now extends from APIClientBase with clearly defined getters for DataClient and clusterOptions. This refactoring enforces a cleaner separation between asynchronous remote calls and local caching, making the API more robust in multi-process scenarios.

site/docs/advanced/cluster-client.md (3)

73-73: Destructured Import for Base Module
The change to const { Base } = require('sdk-base'); follows modern import conventions and improves clarity.


171-172: Updated Destructured Imports in RegistryClient Example
Switching to const { parse } = require('node:url'); and const { Base } = require('sdk-base'); aligns with current Node.js best practices.


239-239: Correct Usage of URL Parsing in Publish Method
Using this._registered.get(key).map((url) => parse(url, true)) is concise and leverages the updated import of parse. Ensure that passing true meets the parsing needs by returning a URL object.

@fengmk2 fengmk2 merged commit 762e301 into next Feb 3, 2025
32 of 34 checks passed
@fengmk2 fengmk2 deleted the egg-onerror branch February 3, 2025 03:25
fengmk2 pushed a commit that referenced this pull request Feb 3, 2025
[skip ci]

## [4.0.5](v4.0.4...v4.0.5) (2025-02-03)

### Bug Fixes

* use @eggjs/onerror ([#5389](#5389)) ([762e301](762e301))
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