refactor: change key of symbols and bump routup to v5.0.0-beta.4#772
refactor: change key of symbols and bump routup to v5.0.0-beta.4#772
Conversation
📝 WalkthroughWalkthroughThe PR bumps Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
packages/body/test/unit/module.spec.ts (1)
149-149: Assert error identity, not only HTTP 500.This currently passes for any internal error. Add an assertion that verifies the response/error corresponds to
PluginNotInstalledErrorfor stronger regression coverage.Suggested test hardening
expect(response.status).toEqual(500); + const text = await response.text(); + expect(text).toContain('PluginNotInstalledError');🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/body/test/unit/module.spec.ts` at line 149, The test currently only asserts expect(response.status).toEqual(500) which is too broad; update the test in module.spec.ts to also assert the error identity for PluginNotInstalledError by either importing PluginNotInstalledError and asserting the returned error is an instance of it (e.g., expect(response.body.error).toBeInstanceOf(PluginNotInstalledError)) or by asserting the error name/code in the response payload (e.g., expect(response.body.error.name).toEqual('PluginNotInstalledError') or expect(response.body.error.code).toEqual('PluginNotInstalledError')), keeping the existing status assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cookie/src/request.ts`:
- Line 5: Replace the package-local symbol with a global symbol so the cookie
store key is identical across module instances: change the CookieSymbol
declaration used by createHandler() and useRequestCookies() from
Symbol('ReqCookie') to a Symbol.for(...) call (e.g., Symbol.for('ReqCookie') or
another stable key string) so PluginNotInstalledError checks reference the same
symbol instance across duplicate dependency graphs.
In `@packages/decorators/src/utils/meta.ts`:
- Line 3: Replace the instance-local symbol with a globally-registered symbol so
metadata is shared across package instances: in the file where the const symbol
= Symbol('DecoratorMeta') is declared (the symbol variable used for decorator
metadata lookup), change it to use Symbol.for('DecoratorMeta') so the symbol is
resolved from the global symbol registry and metadata attached by one bundle is
visible to other bundles.
In `@packages/i18n/src/constants.ts`:
- Around line 1-2: The request-store symbols are currently created with
Symbol(...) so different installed/bundled copies can produce different
identities; replace their creation to use Symbol.for('ReqI18nInstance') and
Symbol.for('ReqI18nLocale') instead so the symbols are registered in the global
symbol registry and shared across module instances (update the declarations for
REQUEST_INSTANCE_SYMBOL and REQUEST_LOCALE_SYMBOL accordingly).
In `@packages/rate-limit/src/request.ts`:
- Line 6: The module creates RateLimitSymbol with Symbol() which is module-local
and can differ across bundled/duplicated instances causing
useRequestRateLimitInfo/setRequestRateLimitInfo to miss the stored value and
throw PluginNotInstalledError; change the declaration of RateLimitSymbol to use
Symbol.for('ReqRateLimit') so the symbol is global across module instances, keep
the same identifier RateLimitSymbol and ensure setRequestRateLimitInfo and
useRequestRateLimitInfo continue to read/write using that symbol.
---
Nitpick comments:
In `@packages/body/test/unit/module.spec.ts`:
- Line 149: The test currently only asserts expect(response.status).toEqual(500)
which is too broad; update the test in module.spec.ts to also assert the error
identity for PluginNotInstalledError by either importing PluginNotInstalledError
and asserting the returned error is an instance of it (e.g.,
expect(response.body.error).toBeInstanceOf(PluginNotInstalledError)) or by
asserting the error name/code in the response payload (e.g.,
expect(response.body.error.name).toEqual('PluginNotInstalledError') or
expect(response.body.error.code).toEqual('PluginNotInstalledError')), keeping
the existing status assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 33d30f8c-2a35-49d5-bc5a-f3a5f0c5a068
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (21)
package.jsonpackages/assets/package.jsonpackages/basic/package.jsonpackages/body/package.jsonpackages/body/src/constants.tspackages/body/src/helpers/read.tspackages/body/test/unit/module.spec.tspackages/cookie/package.jsonpackages/cookie/src/request.tspackages/decorators/package.jsonpackages/decorators/src/utils/meta.tspackages/i18n/package.jsonpackages/i18n/src/constants.tspackages/i18n/src/use-translator.tspackages/prometheus/package.jsonpackages/query/package.jsonpackages/query/src/request.tspackages/rate-limit-redis/package.jsonpackages/rate-limit/package.jsonpackages/rate-limit/src/request.tspackages/swagger/package.json
Summary by CodeRabbit