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

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

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

Conversation

simllll
Copy link

@simllll simllll commented Nov 2, 2020

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
Copy link
Author

simllll commented Nov 2, 2020

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
Copy link
Author

simllll commented Nov 2, 2020

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
Copy link

stale bot commented Jan 1, 2021

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 stale bot added the wontfix label Jan 1, 2021
@stale stale bot closed this Jan 9, 2021
@erdii erdii reopened this Mar 17, 2021
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