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

Refactor (Core): Move from scoped variables to node built-in AsyncLocalStorage #1285

Merged
merged 2 commits into from
Aug 20, 2023

Conversation

SBoudrias
Copy link
Owner

Rationale: State management through the scoped variables did (and could again, or might still do so in narrow cases) cause leaks in context around async operations and cleanup phases. I think using AsyncLocalStorage might improve this caveats by ensuring a stable context.

@codecov
Copy link

codecov bot commented Aug 19, 2023

Codecov Report

Patch coverage: 76.71% and project coverage change: +0.23% 🎉

Comparison is base (3731d64) 77.00% compared to head (bcedd26) 77.23%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1285      +/-   ##
==========================================
+ Coverage   77.00%   77.23%   +0.23%     
==========================================
  Files          41       41              
  Lines        4127     4134       +7     
  Branches      729      722       -7     
==========================================
+ Hits         3178     3193      +15     
+ Misses        229      227       -2     
+ Partials      720      714       -6     
Files Changed Coverage Δ
packages/core/src/index.mts 82.67% <76.71%> (+2.38%) ⬆️

... and 1 file with indirect coverage changes

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

@@ -381,23 +381,6 @@ describe('Error handling', () => {
await expect(answer).rejects.toThrowError('Error in render function');
});

it('Prevent trying to run 2 prompts at once.', async () => {
Copy link
Owner Author

Choose a reason for hiding this comment

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

Side effect, it becomes theoretically possible to run 2 inquirer prompts at once.

This is unlikely to have much benefits but:

  1. Could be theoretically possible to run prompts on different streams (if Node Readline allow it - it used to have singleton conflicts)
  2. When running tests today, if a test fail Inquirer doesn't cleanup. This won't happen anymore 🎉

@SBoudrias SBoudrias merged commit 948dfd9 into master Aug 20, 2023
9 of 10 checks passed
@SBoudrias SBoudrias deleted the async-storage-hooks branch August 20, 2023 17:19
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