question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] _checkPrototype function loops indefinitely when calling Invoke-WebRequest cmdlet against a docs.microsoft.com webpage

See original GitHub issue

Description/Screenshot

This is related with the issue described at https://docs.microsoft.com/en-us/answers/questions/329655/powershell-invoke-webrequest-to-httpsdocsmicrosoft.html. Upon debugging the issue, it seems we loop indefinitely in a javascript function from this SDK, hence this issue.

The goal here is to verify that changes have recently been done in this area and if any IE quirk may need to be accounted for.

Steps to Reproduce

  1. Open a PowerShell command line and type in the following command:

Invoke-WebRequest -Uri https://docs.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/windowsdesktop-whatsnew

  1. The command may never return and you’ll see powershell.exe going 100% CPU indefinitely

From the Invoke-WebRequest documentation:

The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or web service. It parses the response and returns collections of links, images, and other significant HTML elements.

This parsing is performed by using IE’s mshtml.dll module, which may be part of the problem. Inspecting the CPU hogging PowerShell process, it seems we loop indefinitely in the following function:

	function _checkPrototype(classProto, thisTarget) {
        var thisProto = _getObjProto$1(thisTarget);
        while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto)) {
            if (thisProto === classProto) {
                return true;
            }
            thisProto = _getObjProto$1(thisProto);
        }
        return false;
    }
  • OS/Browser: Windows 10 20H2
  • SDK Version [e.g. 22]: latest stable
  • How you initialized the SDK:

Expected behavior

The command returns with the DOM elements parsed. This can be observed by targeting any other URL for the Invoke-WebRequest cmdlet, not matter how complex the page may be.

Additional context

This is affecting enterprise customers that rely on this method to parse docs.microsoft.com content for certain internal processes.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MSNevcommented, Apr 16, 2021

I’m moving this issue to the dynamic proto project as that is where the issue is occurring https://github.com/microsoft/DynamicProto-JS/issues/31

0reactions
github-actions[bot]commented, Apr 23, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] _checkPrototype function loops indefinitely when calling ...
Upon debugging the issue, it seems we loop indefinitely... ... indefinitely when calling Invoke-WebRequest cmdlet against a docs.microsoft.com webpage #31.
Read more >
Powershell Invoke-WebRequest to https://docs.microsoft.com
we tried to invoke a webrequest with powershell to ... seems to be blocked with powershell running into an endless loop without error....
Read more >
Invoke-WebRequest (Microsoft.PowerShell.Utility)
The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or web service. It parses the response and returns collections of...
Read more >
Powershell Invoke-WebRequest to https://docs.microsoft.com
You can access the RawContent, RawContentLength , Content, Headers, etc. However, the parsing of the data fails by entering a loop. E.g., $x....
Read more >
Invoke-RestMethod - PowerShell - Microsoft Learn
The Invoke-RestMethod cmdlet sends HTTP and HTTPS requests to Representational State Transfer (REST) web services that return richly structured data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found