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
Emit a warning if sandbox restore has not been called or have a non-sandbox API #2356
Comments
I like the idea of a (configurable?) threshold for registered fakes in the default sandbox. Would you like to send a PR for this to help avoid this frustration for others? |
Sure, will try to make the time for that. |
Wouldn't it be better if manually restoring stubs didn't cause memory leaks in the first place? Did you look into a solution that removes the reference from the sandbox that is tracking the stub? |
The problem isn't that individual restores was causing a memory leak; the problem is that we were never restoring the fakes or the sandbox because it's not intuitively obvious that you need to do so. It makes sense that if you're stubbing live objects ( |
What I meant was that we could have found a solution under the hood, that would remove the stub from the collection when you call it's own Nothing new for the users to worry about and no messages in the console either. I think #2357 got merged too soon, before other options had been explored. Ping @fatso83 |
Well, in our case we weren't calling each fake's own |
That assumes you restore something. That is not given. As here. |
Is your feature request related to a problem? Please describe.
Our team has gone many many years using this wonderful software unaware that sinon retained references to fakes in a global sandbox. It's documented well, but either we didn't find our way to that specific page before or we just didn't RTFM properly. It wasn't until our OOM issues got really frustrating with a large test suite that we finally figured out that we weren't restoring this global sandbox.
Describe the solution you'd like
There are two things that could have helped us here:
const someStub = sinon.stub().returns('foo');
that it's retained elsewhere in case you wanted to do a bulk operation on all your fakes.The text was updated successfully, but these errors were encountered: