FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: do not block event loop while doing cleanups by simllll · Pull Request #216 · node-cache/node-cache · GitHub

fix: do not block event loop while doing cleanups - #216

Open
simllll wants to merge 4 commits into
node-cache:masterfrom
simllll:patch-1
Open

fix: do not block event loop while doing cleanups#216
simllll wants to merge 4 commits into
node-cache:masterfrom
simllll:patch-1

Conversation

simllll commented Nov 2, 2020

Copy link
Copy Markdown

potenitally fixes #215, needs more testing though

note: I have no idea of coffeescript, is my fix syntacitally correct?

potenitally fixes node-cache#215, needs more testing though

note: I have no idea of coffeescript, is my fix syntacitally correct?

simllll commented Nov 2, 2020
edited
Loading

Copy link
Copy Markdown
Author

Oh right, some test fail now due to the async behaviour. Either we await the setImmediate callback (Can we use async / await in coffeescript?) or we change some other code logic here to let this thing happen asynchronously.

simllll commented Nov 2, 2020

Copy link
Copy Markdown
Author

Javascript code that solves the issue on my side:

async _checkData(startPeriod = true) {
        var key, ref, value;
        boundMethodCheck(this, NodeCache);
        ref = this.data;
        // run the housekeeping method
				var i = 0;
        for (key in ref) {
          value = ref[key];
					this._check(key, value);
					if (i % 10 === 0) {
						await new Promise(resolve => setImmediate(resolve));
					}
					i++;
        }
....

this potentially breaks support for older node versions, sorry, I have no idea about coffeescript, just testing out ;)

stale Bot commented Jan 1, 2021

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale Bot added the wontfix label Jan 1, 2021
stale Bot closed this Jan 9, 2021
erdii reopened this Mar 17, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can 'node-cache' block node event loop?

2 participants


Back | FazBrowse Home | New Git URL