fix(network): apply connection timeout in server and extension hosts
Complete the runtime entrypoints from #3404 without changing address-family selection.
This commit is contained in:
@@ -1,9 +1,25 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import net from 'node:net';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
import { applyConnectAttemptTimeout, CONNECT_ATTEMPT_TIMEOUT_MS } from './network-defaults.js';
|
||||
|
||||
describe('applyConnectAttemptTimeout', () => {
|
||||
it('initializes the server entrypoint in a fresh Node process', () => {
|
||||
const serverUrl = new URL('../index.js', import.meta.url).href;
|
||||
const result = spawnSync('node', ['--input-type=module', '--eval', `
|
||||
import net from 'node:net';
|
||||
import assert from 'node:assert/strict';
|
||||
const family = net.getDefaultAutoSelectFamily();
|
||||
net.setDefaultAutoSelectFamilyAttemptTimeout(250);
|
||||
await import(${JSON.stringify(serverUrl)});
|
||||
assert.equal(net.getDefaultAutoSelectFamilyAttemptTimeout(), 5000);
|
||||
assert.equal(net.getDefaultAutoSelectFamily(), family);
|
||||
process.exit(0);
|
||||
`], { encoding: 'utf8', timeout: 15_000, windowsHide: true });
|
||||
expect(result.status, result.stderr).toBe(0);
|
||||
});
|
||||
|
||||
it('raises the per-attempt connect timeout on runtimes that expose the setter', () => {
|
||||
const previous = net.getDefaultAutoSelectFamilyAttemptTimeout();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user