googleapis / google-api-nodejs-client

Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
https://googleapis.dev/nodejs/googleapis/latest/
Apache License 2.0
11.26k stars 1.9k forks source link

HTTP/2 option ignore timeout option #3187

Open gring2 opened 1 year ago

gring2 commented 1 year ago

Environment details

Steps to reproduce

  1. set http2 and timeout options to google.options
    google.options({http2: true, timeout: 1})
  2. 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);
ddelgrosso1 commented 1 year ago

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.

ddelgrosso1 commented 8 months ago

Changing to feature request as things work as intended but there is a lot of mixing of types and arguments that could be handled a lot better.

gring2 commented 8 months ago

Thank you for your work.

if this problem is solved it will be great help to improve my user experience.