mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +00:00

Calling JS during GC is a no-no. So intead create a queue of all ids that need to have their destroy() callback called and call them later. Removed checking destroy() in test-async-wrap-uid because destroy() can be called after the 'exit' callback. Missing a reliable test to reproduce the issue that caused the FATAL_ERROR. PR-URL: https://github.com/nodejs/node/pull/9753 Fixes: https://github.com/nodejs/node/issues/8216 Fixes: https://github.com/nodejs/node/issues/9465 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
52 lines
915 B
JavaScript
52 lines
915 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const fs = require('fs');
|
|
const assert = require('assert');
|
|
const async_wrap = process.binding('async_wrap');
|
|
|
|
const storage = new Map();
|
|
async_wrap.setupHooks({ init, pre, post });
|
|
async_wrap.enable();
|
|
|
|
function init(uid) {
|
|
storage.set(uid, {
|
|
init: true,
|
|
pre: false,
|
|
post: false,
|
|
});
|
|
}
|
|
|
|
function pre(uid) {
|
|
storage.get(uid).pre = true;
|
|
}
|
|
|
|
function post(uid) {
|
|
storage.get(uid).post = true;
|
|
}
|
|
|
|
fs.access(__filename, function(err) {
|
|
assert.ifError(err);
|
|
});
|
|
|
|
fs.access(__filename, function(err) {
|
|
assert.ifError(err);
|
|
});
|
|
|
|
async_wrap.disable();
|
|
|
|
process.once('exit', function() {
|
|
assert.strictEqual(storage.size, 2);
|
|
|
|
for (const item of storage) {
|
|
const uid = item[0];
|
|
const value = item[1];
|
|
assert.strictEqual(typeof uid, 'number');
|
|
assert.deepStrictEqual(value, {
|
|
init: true,
|
|
pre: true,
|
|
post: true,
|
|
});
|
|
}
|
|
});
|