Skip to content

Instantly share code, notes, and snippets.

@codebytere
Last active May 17, 2021 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codebytere/8a8586d5c58399f23f9398ce763ee218 to your computer and use it in GitHub Desktop.
Save codebytere/8a8586d5c58399f23f9398ce763ee218 to your computer and use it in GitHub Desktop.
http2-exit-cleanly
<!-- Empty -->
const childProcess = require('child_process')
const path = require('path')
const { stdout, stderr, status } = childProcess.spawnSync(process.execPath, [path.join(__dirname, 'renderer.js')], {
env: { ELECTRON_RUN_AS_NODE: 'true' }
});
console.log(stderr.toString(), stdout.toString())
process.exit(status)
const { strictEqual } = require('assert');
const { createServer, connect } = require('http2');
const { spawnSync } = require('child_process');
if (process.argv[2] !== 'child') {
const {
stdout, stderr, status
} = spawnSync(process.execPath, [__filename, 'child'], { encoding: 'utf8' });
strictEqual(stderr, '');
strictEqual(stdout, '');
strictEqual(status, 0);
} else {
const server = createServer();
server.listen(0, () => {
const client = connect(`http://localhost:${server.address().port}`);
client.on('connect', () => {
client.close();
server.close();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment