Skip to content

Error object stored on Runnable._trace leaks memory #3119

Closed
Urigo/tortilla
#64

Description

FYI: In V8, Error objects keep closures alive until the err.stack property is accessed, which prevents collection of the closure (and associated objects) until the Error objects die.

Mocha creates a long-living Error for each Runnable:

this._trace = new Error('done() called multiple times');
.

Would it make sense to either 1. store a string message instead of an Error, or 2. clear Error.stack, or 3. format Error.stack eagerly instead?

See also: https://crbug.com/v8/7142 and https://twitter.com/wSokra/status/935790750188625920.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

semver-patchimplementation requires increase of "patch" version number; "bug fixes"type: buga defect, confirmed by a maintainer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions