docs: fix app.currentContext example (read the getter, don't assign to it)#1978
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request corrects a code example in the Koa API documentation. The example for 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the documentation example for Sequence diagram for using app.currentContext getter in docs examplesequenceDiagram
participant Request
participant Middleware as app_middleware
participant Application as app
participant Function as callSomeFunction
Request->>app_middleware: handle request
app_middleware->>app: set ctxStorage store
Request-->>Function: later callSomeFunction()
Function->>app: currentContext
app-->>Function: ctx from ctxStorage.getStore()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1978 +/- ##
=======================================
Coverage 99.90% 99.90%
=======================================
Files 9 9
Lines 2109 2109
=======================================
Hits 2107 2107
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The
app.currentContextexample assigns to the property:But
currentContextis a getter-only accessor (lib/application.js):There is no setter, so assigning to it throws
TypeError: Cannot set property currentContext of #<Application> which has only a getterin strict mode (which is the default for ES modules / class bodies). The assignment is also backwards from what the surrounding text describes — "this will return the current context for the request" — so the example should read the property, which is exactly what the adjacent v3.1.0 example does viaasyncLocalStorage.getStore().This changes the example to read the getter:
Docs only.
Summary by Sourcery
Documentation:
app.currentContextdocumentation example to read from the getter instead of assigning to it.Summary by CodeRabbit
Release Notes