File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -52,17 +52,23 @@ async () => {
5252 if ( ! outstanding ) {
5353 debug ( `Getting token with client credentials` ) ;
5454
55- outstanding = client . grant ( { grant_type : 'client_credentials' } )
56-
55+ let grantWrapFunc = async ( ) => {
56+ let result = client . grant ( { grant_type : 'client_credentials' } )
57+ try {
58+ return await result ;
59+ } catch ( err ) {
60+ if ( err && err . statusCode === 429 ) {
61+ await _sleep ( 1000 ) ;
62+ return await grantWrapFunc ( ) ;
63+ }
64+ throw err ;
65+ }
66+ }
67+ outstanding = grantWrapFunc ( ) ;
5768 try {
5869 token_set = await outstanding
70+ } finally {
5971 outstanding = undefined
60- } catch ( err ) {
61- outstanding = undefined
62- if ( err && err . statusCode === 429 ) {
63- await _sleep ( 1000 ) ;
64- await oauthtoken_set . refresh ( ) ;
65- }
6672 }
6773
6874 debug ( `Got fresh token: ${ JSON . stringify ( token_set ) } ` ) ;
You can’t perform that action at this time.
0 commit comments