Skip to content

Instantly share code, notes, and snippets.

@andywer
Last active July 15, 2017 11:41
Show Gist options
  • Save andywer/0f23eaa2a8b91db4bd2f1fcc51b69bf9 to your computer and use it in GitHub Desktop.
Save andywer/0f23eaa2a8b91db4bd2f1fcc51b69bf9 to your computer and use it in GitHub Desktop.
Leakage async: Real world test
{
"scripts": {
"test": "mocha"
},
"engines": {
"node": ">= 7.0"
},
"devDependencies": {
"leakage": "./path/to/local/leakage/branch/feature/async-support",
"mocha": "^3.2.0",
"threads": "0.7.2"
}
}
/**
* Works well! Fails when using threads@0.7.1, but succeeds for threads@0.7.2
* which includes a memory leak fix for `thread.promise()`.
* See https://github.com/andywer/threads.js/pull/32
*/
const { iterate } = require('leakage')
const { spawn } = require('threads')
describe('threads.js', () => {
it('does not leak', () => {
const thread = spawn()
return iterate(100, () => thread.run((input, done) => done()).send().promise())
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment