0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-async-hooks-vm-gc.js
Bryan English 0e8bd79cbb async_hooks: check for empty contexts before removing
This way we don't end up attempting to SetPromiseHooks on contexts that
have already been collected.

Fixes: https://github.com/nodejs/node/issues/39019

PR-URL: https://github.com/nodejs/node/pull/39095
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
2021-06-21 21:29:44 -04:00

16 lines
350 B
JavaScript

// Flags: --expose-gc
'use strict';
require('../common');
const asyncHooks = require('async_hooks');
const vm = require('vm');
// This is a regression test for https://github.com/nodejs/node/issues/39019
//
// It should not segfault.
const hook = asyncHooks.createHook({ init() {} }).enable();
vm.createContext();
globalThis.gc();
hook.disable();