Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot update NPM catalog - refresh failed #99

Closed
asuchac opened this issue May 6, 2015 · 13 comments
Closed

Cannot update NPM catalog - refresh failed #99

asuchac opened this issue May 6, 2015 · 13 comments

Comments

@asuchac
Copy link

asuchac commented May 6, 2015

Using NTVS 1.0.
I clicked 'Refresh' button in window 'Install New npm packages'. After some time, I got error message 'Refresh failed - see output'. Same error repeatedly. Here is npm install output:

Registry url: https://registry.npmjs.org/
Current Time: 06/05/2015 3:11:14 PM
Last Refreshed: 02/12/2014 9:52:36 AM
Number of Results: 115506
Registry url: https://registry.npmjs.org/
Path to npm: C:\Program Files\nodejs\npm.cmd
Downloading package cache to C:\Users\ales\AppData\Local\Microsoft\Node.js Tools\NpmCache\2fa5acfe-4767-4521-9f96-02363f57ec13\since_packages.json
System.Net.WebException: The remote server returned an error: (503) Server Unavailable.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NodejsTools.Npm.SPI.NpmGetCatalogCommand.d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NodejsTools.Npm.SPI.NpmGetCatalogCommand.d__5a.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.NodejsTools.Npm.SPI.NpmGetCatalogCommand.d__3f.MoveNext()
Download or parsing failed - deleting C:\Users\ales\AppData\Local\Microsoft\Node.js Tools\NpmCache. Try refreshing the catalog again. Otherwise restart Visual Studio, and try again.
Deleting 2fa5acfe-4767-4521-9f96-02363f57ec13
System.Net.WebException: The remote server returned an error: (503) Server Unavailable.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NodejsTools.Npm.SPI.NpmGetCatalogCommand.d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NodejsTools.Npm.SPI.NpmGetCatalogCommand.d__5a.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.NodejsTools.Npm.SPI.NpmGetCatalogCommand.d__3f.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.NodejsTools.Npm.SPI.NpmCommander.d__0.MoveNext()

@mousetraps
Copy link
Contributor

Try it again. npm's servers appear to have had a temporary glitch. I got this at first when I tried hitting the url in the browser.
image

But it's working fine for me now. 😃

@asuchac
Copy link
Author

asuchac commented May 6, 2015

Excellent hint & quick reaction, but: just tried https://registry.npmjs.org/-/all from the browser, shows complete catalog. After that, tried again from NTVS 1.0 plugged in VS 2013 and got the same error, 503.

I wonder if NTVS correctly calls this link. Last time my catalog was successfully updated was 1st Dec 2014, it was on NTVS RC - maybe some bug introduced in ver 1.0?

@mousetraps
Copy link
Contributor

Interesting. It works for me with the latest bits, and we haven't made many changes to npm catalog downloading since RC on Nov 24. The only change we made that would have affected it would produce a 404 if something were to go wrong... not a 503.

Did you make any network-related changes recently?

Otherwise, try this:

  1. Can you zip up and send the NpmCache Folder in %localappdata%\Microsoft\Node.js Tools? This will help us investigate what's going on.
  2. Then go ahead and delete the NpmCache folder (or rename it, your pick), and try refreshing again. This will download all the packages (hitting the /-/all url - right now, it's actually hitting a slightly different one, which we normally print in the output to help debug such issues, but I now realize we print it too late

@asuchac
Copy link
Author

asuchac commented May 6, 2015

OK, I've found a workaround. Go to folder:
"C:\Users\YOUR_USERNAME\AppData\Local\Microsoft\Node.js Tools" and delete subfolder NpmCache.
Then NTVS downloads the whole thing and it works. I suspect the partial updates is the problem, see at source code, particularly:
nodejstools-master\Nodejs\Product\Npm\SPI\NpmGetCatalogCommand.cs:

    private async Task<string> DownloadPackageJsonCache(Uri registry, string cachePath, long refreshStartKey = 0) {
        string relativeUri, filename;

        if (refreshStartKey > 0) {
            relativeUri = String.Format("-/all/since?stale=update_after&startkey={0}", refreshStartKey);
            filename = Path.Combine(cachePath, "since_packages.json");
        } else {
            relativeUri = "-/all";
            filename = Path.Combine(cachePath, "all_packages.json");
        }

@mousetraps
Copy link
Contributor

Commenting race condition 😃

Any chance that folder you just deleted is in your recycle bin?

@asuchac
Copy link
Author

asuchac commented May 6, 2015

Well, I moved it away - anything particular I have to look at? Or I can zip it and make available for you.

@mousetraps
Copy link
Contributor

Yeah, zipped up would be great

@mousetraps
Copy link
Contributor

I need to run it through the debugger/fiddler to figure out the relative url it's trying to hit, and why it's unavailable. Because even if startkey is set wrong, you'll get a 400, not a 503, so something's not adding up.

@asuchac
Copy link
Author

asuchac commented May 6, 2015

It is ready for you:
http://www.sherlock.com.au/sherlock32/NpmCache.zip
Size = 31.4 MB. Good luck and thank you for excellent responses :-)

@mousetraps
Copy link
Contributor

Np, glad you got it all sorted out. Download successful, thank you!

Enjoy 1.0 😃

@bogacg
Copy link

bogacg commented Sep 3, 2015

I had the same problem. VS 2013 and NTVS.Dev.2015-08-04.VS.2013 installed. It installs catalog but after install it just gets stuck in update database phase. Let me know if you need zipped NpmCache folder. My last update was on around 20.08.2015 and after that it tried to download a 15Mb catalog update. Deleting folder and download/remake catalog (103 Mb) solved this problem for me.

@billti
Copy link
Member

billti commented Sep 10, 2015

I fixed this in the pull request for #398. We'll be pushing out a build shortly with the issue addressed.

@billti billti closed this as completed Sep 10, 2015
@msedek
Copy link

msedek commented Jan 10, 2017

well this issue was on 2015, just today installed the node 6.9.4 from https://nodejs.org/en/ and trying to add the package from my fresh installed visual studio 2017 and had the same issue... had to follow the workaround from asuchac commented on 6 May 2015 and got it working so, they didnt manage to fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants