xref: /third_party/node/test/parallel/test-http-client-timeout-option-with-agent.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Test that the request `timeout` option has precedence over the agent
41cb0ef41Sopenharmony_ci// `timeout` option.
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst { mustCall } = require('../common');
71cb0ef41Sopenharmony_ciconst { Agent, get } = require('http');
81cb0ef41Sopenharmony_ciconst { strictEqual } = require('assert');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst request = get({
111cb0ef41Sopenharmony_ci  agent: new Agent({ timeout: 50 }),
121cb0ef41Sopenharmony_ci  lookup: () => {},
131cb0ef41Sopenharmony_ci  timeout: 100
141cb0ef41Sopenharmony_ci});
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cirequest.on('socket', mustCall((socket) => {
171cb0ef41Sopenharmony_ci  strictEqual(socket.timeout, 100);
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  const listeners = socket.listeners('timeout');
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  strictEqual(listeners.length, 2);
221cb0ef41Sopenharmony_ci  strictEqual(listeners[1], request.timeoutCb);
231cb0ef41Sopenharmony_ci}));
24

Indexes created Thu Nov 07 10:32:03 CST 2024