@octokit/core: authStrategy & custom logger

node v10.24.1
version: 1.0.0
endpointsharetweet
The code below should log [WARN] [@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: 1, wait: 1s) But it instead logs [@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: 1, wait: 1s) Because the custom logger passed to the Octokit constructor is not inherited by createAppAuth.
const { createAppAuth } = require("@octokit/auth-app"); const { Octokit } = require("@octokit/core") const nock = require('nock') nock.disableNetConnect() // dummy key const PRIVATE_KEY = `-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5 1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh 3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2 pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ 37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0= -----END RSA PRIVATE KEY-----`; const octokit = new Octokit({ log: { debug: (msg, ...extraArgs) => console.debug('[DEBUG] ' + msg, ...extraArgs), info: (msg, ...extraArgs) => console.info('[INFO] ' + msg, ...extraArgs), warn: (msg, ...extraArgs) => console.warn('[WARN] ' + msg, ...extraArgs), error: (msg, ...extraArgs) => console.error('[ERROR] ' + msg, ...extraArgs) }, authStrategy: createAppAuth, auth: { id: 1, privateKey: PRIVATE_KEY, installationId: 2 } }) nock('https://api.github.com') .post('/app/installations/2/access_tokens') .reply(201, { token: 'installation-token-123', permissions: {} }) .get('/repos/octokit/core.js') .reply(401) .get('/repos/octokit/core.js') .reply(200, { ok: true }) octokit.request('GET /repos/octokit/core.js') // this currently logs // // > "[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: 1, wait: 1s)" // // but should instead log // // > "[WARN] [@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: 1, wait: 1s)" //
Loading…

no comments

    sign in to comment