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

Initialize context.state sooner #1732

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

krisstern
Copy link

Fixes #1646

Description

Allow context creation an overridable Koa option.

Checklist

  • I have ensured my pull request is not behind the main or master branch of the original repository.
  • I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
  • I have written a commit message that passes commitlint linting.
  • I have ensured that my code changes pass linting tests.
  • I have ensured that my code changes pass unit tests.
  • I have described my pull request and the reasons for code changes along with context if necessary.

@codecov
Copy link

codecov bot commented Dec 24, 2022

Codecov Report

Base: 99.61% // Head: 99.61% // No change to project coverage 👍

Coverage data is based on head (3a3f9b3) compared to base (bec13ec).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1732   +/-   ##
=======================================
  Coverage   99.61%   99.61%           
=======================================
  Files           5        5           
  Lines         521      521           
  Branches      145      145           
=======================================
  Hits          519      519           
  Misses          2        2           
Impacted Files Coverage Δ
lib/context.js 100.00% <ø> (ø)
lib/application.js 98.43% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@krisstern krisstern force-pushed the initialize-context-state-sooner branch from 91528e4 to 5c3e296 Compare January 25, 2023 02:55
Copy link

@antaranyan antaranyan left a comment

Choose a reason for hiding this comment

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

Change looks fine for what it does.

Consider asserting this in context state test.

@krisstern
Copy link
Author

Change looks fine for what it does.

Consider asserting this in context state test.

Hi @antaranyan Sure, I have just modified the exisitng test for context > state.

@@ -208,7 +208,7 @@ module.exports = class Application extends Emitter {
request.response = response
response.request = request
context.originalUrl = request.originalUrl = req.url
context.state = {}
context.state = Object.assign({}, context.state)

Choose a reason for hiding this comment

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

The whole point of ctx.state as I see it is to ensure there's no state bleed between requests.
As far as I see it, this change defeats this original purpose.

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.

initialize context.state sooner
4 participants