Skip to content

Conversation

@sadasant
Copy link
Contributor

@sadasant sadasant commented Apr 29, 2021

This is a proposal. I can't get this repo to work locally yet! Lerna doesn't get installed in my VM.

Something similar to this would:
Fix #3476

@samuelkubai samuelkubai marked this pull request as ready for review May 12, 2021 14:09
@samuelkubai
Copy link
Contributor

Fixed the failing test cases and linting errors and I think the pull request is ready for review by the team


if (response.body && response.body.error === Constants.AUTHORIZATION_PENDING) {
// user authorization is pending. Sleep for polling interval and try again
this.logger.info(response.body.error_description || "no_error_description");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer something more meaningful here. Also, errors should be logged using this.logger.error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the "no_error_description" with "Authorization pending. Continue polling.", the response description is still most meaningful here as it is phrased like "AADSTS70016: OAuth 2.0 device flow error. Authorization is pending. Continue polling. Trace ID: 01707a0c-640b-4049-8cbb-ee2304dc0700 Correlation ID: 78b0fdfc-dd0e-4dfb-b13a-d316333783f6 Timestamp: 2020-03-26 22:54:14Z" with a lot of useful information for debugging.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message itself does not seem appropriate to categorize as an error message, I still think this.logger.info is the better categorization of the message.


await delay(pollingIntervalMilli);
} else {
return response.body;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a verbose log message here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

* @param t number
* @param value T
*/
function delay<T>(t: number, value?: T): Promise<T | void> {
Copy link
Contributor

@jasonnutter jasonnutter May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be defined somewhere more easily reusable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this function and continuePolling are defined in different ways. I would propose they are both added as members of this class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to making them class functions. delay can also be a utility function instantiated as needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the delay function to the TimeUtils utility class and made continuePolling a member of the class.

- make the continuePolling function a class member
- move the delay function to the TimeUtils utility
- add a more descriptive polling alternate message
- add a verbose message on polling completion
@samuelkubai samuelkubai merged commit 24b8c04 into AzureAD:dev May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid calling asynchronous requests from setInterval()

4 participants