mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
We must back up the value of `_env` before calling the async work complete callback, because the complete callback may delete the instance in which `_env` is stored by calling `napi_delete_async_work`, and because we need to use it after the complete callback has completed. Fixes: https://github.com/nodejs/node/issues/20966 PR-URL: https://github.com/nodejs/node/pull/21129 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
15 lines
449 B
JavaScript
15 lines
449 B
JavaScript
'use strict';
|
|
const common = require('../../common');
|
|
const assert = require('assert');
|
|
const test_async = require(`./build/${common.buildType}/test_async`);
|
|
const iterations = 500;
|
|
|
|
let x = 0;
|
|
const workDone = common.mustCall((status) => {
|
|
assert.strictEqual(status, 0, 'Work completed successfully');
|
|
if (++x < iterations) {
|
|
setImmediate(() => test_async.DoRepeatedWork(workDone));
|
|
}
|
|
}, iterations);
|
|
test_async.DoRepeatedWork(workDone);
|