Skip to content

Only decrement activeRequestCount on SetTypings responses#18491

Merged
amcasey merged 1 commit into
microsoft:masterfrom
amcasey:RequestCountDecr
Sep 15, 2017
Merged

Only decrement activeRequestCount on SetTypings responses#18491
amcasey merged 1 commit into
microsoft:masterfrom
amcasey:RequestCountDecr

Conversation

@amcasey
Copy link
Copy Markdown
Member

@amcasey amcasey commented Sep 14, 2017

InvalidateCache responses are triggered by file watchers, rather than by requests.

When I port this to 2.5, I plan to remove the Debug.fail call.

@msftclas
Copy link
Copy Markdown

@amcasey,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

Comment thread src/services/refactors/extractLocal.ts Outdated
@@ -0,0 +1,1342 @@
/// <reference path="../refactorProvider.ts" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you mean to include this file?

Copy link
Copy Markdown
Member Author

@amcasey amcasey Sep 14, 2017

Choose a reason for hiding this comment

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

I always forget that checkout -f doesn't delete new files. 😢

InvalidateCache responses are triggered by file watchers, rather than by
requests.
Copy link
Copy Markdown
Member

@minestarks minestarks left a comment

Choose a reason for hiding this comment

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

:shipit:

Comment thread src/server/server.ts
}

if (this.logger.hasLevel(LogLevel.verbose)) {
this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This still seems like a hazard. You're effectively decrementing by one above to keep track of request/response pairings, yet in this loop you just shift off requests until you find the one you want (with a log "info" message that a request was skipped). Wouldn't this get the activeRequestCount out of sync if it skips them?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, don't mind me. I see this is scheduling the next one from the queue, so should be good.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Though one concern/hazard: This while loop previously was always entered to schedule the next request, other than for the 3 event types explicitly handled in the "if" blocks above. Now you only enter this loop to continue scheduling work "if (response.kind === ActionSet)". Shouldn't it continue to always enter this loop except for any events? (Even if only for future proofing?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can change the check to !invalidate if you think that would be more future proof. Otherwise, it's one-in-one-out, so it doesn't make sense to pull anything off the queue if the message doesn't indicate the completion of a request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems like letting the type system verify exhaustive checks on the string literal types in "TypingInstallerResponse" would be safest to ensure any additions/changes to "response.kind" aren't missed (e.g. https://stackoverflow.com/questions/39419170/how-do-i-check-that-a-switch-block-is-exhaustive-in-typescript ). Possible here?

@amcasey amcasey merged commit 76fd4fe into microsoft:master Sep 15, 2017
@amcasey amcasey deleted the RequestCountDecr branch September 15, 2017 17:50
@amcasey
Copy link
Copy Markdown
Member Author

amcasey commented Sep 15, 2017

Oops, forgot we were going to harden against new message types. Will post a new PR shortly.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants