2017-11-21 12:42:54 +01:00
|
|
|
// Flags: --expose-gc
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('missing crypto');
|
|
|
|
const http2 = require('http2');
|
2024-07-26 01:09:23 -07:00
|
|
|
const { duplexPair } = require('stream');
|
2018-10-12 10:35:08 -07:00
|
|
|
const tick = require('../common/tick');
|
2017-11-21 12:42:54 +01:00
|
|
|
|
|
|
|
// This tests that running garbage collection while an Http2Session has
|
|
|
|
// a write *scheduled*, it will survive that garbage collection.
|
|
|
|
|
|
|
|
{
|
|
|
|
// This creates a session and schedules a write (for the settings frame).
|
|
|
|
let client = http2.connect('http://localhost:80', {
|
2024-07-26 01:09:23 -07:00
|
|
|
createConnection: common.mustCall(() => duplexPair()[0])
|
2017-11-21 12:42:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// First, wait for any nextTicks() and their responses
|
|
|
|
// from the `connect()` call to run.
|
|
|
|
tick(10, () => {
|
|
|
|
// This schedules a write.
|
|
|
|
client.settings(http2.getDefaultSettings());
|
|
|
|
client = null;
|
2025-01-22 15:30:30 -08:00
|
|
|
globalThis.gc();
|
2017-11-21 12:42:54 +01:00
|
|
|
});
|
|
|
|
}
|