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:
@@ -118,6 +118,10 @@ import { createScheduledTaskService } from './lib/scheduled-tasks/service.js';
|
||||
import { createOpenChamberControlService } from './lib/openchamber-control/service.js';
|
||||
import { OpenChamberControlError } from './lib/openchamber-control/error.js';
|
||||
import webPush from 'web-push';
|
||||
import { applyConnectAttemptTimeout } from './lib/network-defaults.js';
|
||||
|
||||
// Background CLI launches enter here in a fresh process, without CLI defaults.
|
||||
applyConnectAttemptTimeout();
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
## Purpose
|
||||
This module fetches quota and usage signals for supported providers in the web server runtime.
|
||||
|
||||
Node server entrypoints apply `../network-defaults.js` before serving requests,
|
||||
including the daemon launched directly through `server/index.js`. Connection
|
||||
attempts get 5 seconds without changing address-family selection. The VS Code
|
||||
extension applies the same policy in its own process at activation.
|
||||
|
||||
## Entrypoints and structure
|
||||
- `packages/web/server/lib/quota/index.js`: public entrypoint imported by `packages/web/server/index.js`.
|
||||
- `packages/web/server/lib/quota/routes.js`: Express route registration for quota endpoints.
|
||||
|
||||
Reference in New Issue
Block a user