googleapis/google-api-nodejs-client

HTTP/2 option ignore timeout option

gring2 opened this issue · 3 comments

Environment details

  • OS:
  • Node.js version: 18.15.0
  • npm version: 9.5.0
  • googleapis version: 112.0.0

Steps to reproduce

  1. set http2 and timeout options to google.options
google.options({http2: true, timeout: 1})
  1. send any request to google apis
google.calendar().events.list({calendarId: ${calendarId}})

I expect api request fails.because it has very short timeout but i got response successfully unlike request through HTTP/1.1
I guess googleapi-common library does not fully support options. because I tested googleapi-common http2 module, the module ignored timeout config.

test code comparing http2 module to node-fetch module

import { request } from 'googleapis-common/build/src/http2';
import nodefetch from 'node-fetch';

request({
  timeout: 1,
  url: 'https://www.google.com',
  headers: { timeout: 1 },
}).then((r) => {
  console.log(r);
});

nodefetch('https://www.google.com', { timeout: 1 }).catch(console.error);

I tracked down the underlying cause and it turns out there is some type confusion between the options that common.http2 accepts and the options ClientHttp2Session which makes the underlying calls accepts. The above mentioned issue will need to be resolved before this issue can be closed. Going to bump the priority of this down in the meantime.