Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm search crashes with GC error when building local cache #12619

Closed
iankronquist opened this issue May 7, 2016 · 56 comments
Closed

npm search crashes with GC error when building local cache #12619

iankronquist opened this issue May 7, 2016 · 56 comments

Comments

@iankronquist
Copy link

OS X 10.11, npm 3.8.6, node 6.0.0 all installed using homebrew. I managed to get this to happen twice in a row before succeeding.

npm search rtfm
npm WARN Building the local index for the first time, please be patient
▐ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟

<--- Last few GCs --->

  131112 ms: Mark-sweep 807.6 (1148.1) -> 782.3 (1130.1) MB, 640.0 / 0 ms [allocation failure] [GC in old space requested].
  131777 ms: Mark-sweep 782.3 (1130.1) -> 782.1 (1131.1) MB, 665.3 / 0 ms [allocation failure] [GC in old space requested].
  132454 ms: Mark-sweep 782.1 (1131.1) -> 782.1 (1125.1) MB, 676.7 / 0 ms [last resort gc].
  133124 ms: Mark-sweep 782.1 (1125.1) -> 782.1 (1119.1) MB, 669.4 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3c83930c9fa9 <JS Object>
    1: fromString(aka fromString) [buffer.js:234] [pc=0x12dd12bb19ab] (this=0x3c8393004189 <undefined>,string=0x1e951b6647c1 <Very long string[166224244]>,encoding=0x3c83930d79a9 <String[4]: utf8>)
    2: from [buffer.js:131] [pc=0x12dd12b35c36] (this=0xb3a135de721 <JS Function Buffer (SharedFunctionInfo 0x2376c91f5a61)>,value=0x1e951b6647c1 <Very long string[166224244]>,encodingOrOffset=0x3c83...

FATAL ERROR: Abort trap: 6

@jhaungs
Copy link

jhaungs commented May 8, 2016

Same here on OSX 10.11, Node 6.1.0 and npm 3.8.9, running npm search tsun.

Trying again, search immediately shows this error, then attempts to build the local index:

npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node/6.1.0/bin/node" "/usr/local/bin/npm" "search" "tsun"
npm ERR! node v6.1.0
npm ERR! npm  v3.8.9

npm ERR! Cannot read property '_updated' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN Building the local index for the first time, please be patient

Then, after several more tries, search does produce some output, then shows a different error:

npm ERR! argv "/usr/local/Cellar/node/6.1.0/bin/node" "/usr/local/bin/npm" "search" "tsun"
npm ERR! node v6.1.0
npm ERR! npm  v3.8.9

npm ERR! Callback called more than once.

Here's the referenced log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.1.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'search',
1 verbose cli   'tsun' ]
2 info using [email protected]
3 info using [email protected]
4 silly mapToRegistry name -/all
5 silly mapToRegistry using default registry
6 silly mapToRegistry registry https://registry.npmjs.org/
7 silly mapToRegistry data Result {
7 silly mapToRegistry   raw: '-/all',
7 silly mapToRegistry   scope: null,
7 silly mapToRegistry   name: null,
7 silly mapToRegistry   rawSpec: '-/all',
7 silly mapToRegistry   spec: '-/all',
7 silly mapToRegistry   type: 'local' }
8 silly mapToRegistry uri https://registry.npmjs.org/-/all
9 info updateIndex /Users/jhaungs/.npm/registry.npmjs.org/-/all/.cache.json
10 verbose correctMkdir /Users/jhaungs/.npm correctMkdir not in flight; initializing
11 verbose stack TypeError: Cannot read property '_updated' of undefined
11 verbose stack     at /usr/local/lib/node_modules/npm/lib/cache/update-index.js:61:26
11 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:210:7
11 verbose stack     at FSReqWrap.oncomplete (fs.js:117:15)
12 verbose cwd /Users/jhaungs/workspaces/angular/ng2-book/code/first_app/angular2-reddit-completed
13 error Darwin 15.4.0
14 error argv "/usr/local/Cellar/node/6.1.0/bin/node" "/usr/local/bin/npm" "search" "tsun"
15 error node v6.1.0
16 error npm  v3.8.9
17 error Cannot read property '_updated' of undefined
18 error If you need help, you may report this error at:
18 error     <https://github.com/npm/npm/issues>
19 verbose exit [ 1, true ]

@iankronquist
Copy link
Author

Yeah, look like the same issue.

@treffiletti
Copy link

I am getting the same issue via node 6.1.0 and npm 3.8.9

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.1.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'search',
1 verbose cli   'connect' ]
2 info using [email protected]
3 info using [email protected]
4 silly mapToRegistry name -/all
5 silly mapToRegistry using default registry
6 silly mapToRegistry registry https://registry.npmjs.org/
7 silly mapToRegistry data Result {
7 silly mapToRegistry   raw: '-/all',
7 silly mapToRegistry   scope: null,
7 silly mapToRegistry   name: null,
7 silly mapToRegistry   rawSpec: '-/all',
7 silly mapToRegistry   spec: '-/all',
7 silly mapToRegistry   type: 'local' }
8 silly mapToRegistry uri https://registry.npmjs.org/-/all
9 info updateIndex /Users/tref/.npm/registry.npmjs.org/-/all/.cache.json
10 verbose correctMkdir /Users/tref/.npm correctMkdir not in flight; initializing
11 verbose stack TypeError: Cannot read property '_updated' of undefined
11 verbose stack     at /usr/local/lib/node_modules/npm/lib/cache/update-index.js:61:26
11 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:210:7
11 verbose stack     at FSReqWrap.oncomplete (fs.js:117:15)
12 verbose cwd /Users/tref/Sites/react/small-frontend
13 error Darwin 15.4.0
14 error argv "/usr/local/Cellar/node/6.1.0/bin/node" "/usr/local/bin/npm" "search" "connect"
15 error node v6.1.0
16 error npm  v3.8.9
17 error Cannot read property '_updated' of undefined
18 error If you need help, you may report this error at:
18 error     <https://github.com/npm/npm/issues>
19 verbose exit [ 1, true ]

@Meligy
Copy link

Meligy commented May 12, 2016

Just came here after seeing the same issue. Was hoping for a workaround or so.

Mac OSX 10.11.4
Node v6.0.1
Npm 3.8.6

@iankronquist
Copy link
Author

@Meligy the workaround seems to be "run it again until it works". It's not a great solution though.

@Meligy
Copy link

Meligy commented May 12, 2016

@iankronquist thanks.

I got another error with no stack trace when I tried again with NPM 3.9.0, then it worked the next time. Not sure because this is the workaround, or because NPM 3.9.0 fixes it.

@ghost
Copy link

ghost commented May 18, 2016

For me neither 3.9.0 nor 3.9.2 have solved the issue.

The funny is, I disabled npm progress but I see this pesky progress bar now again... npm inc. tries to push it hard, as it seems.

npm search eslint-plugin
npm WARN Building the local index for the first time, please be patient
▐ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
<--- Last few GCs --->

   41335 ms: Mark-sweep 818.6 (1182.1) -> 817.9 (1190.1) MB, 509.0 / 0 ms (+ 106.0 ms in 513 steps since start of marking, biggest step 11.0 ms) [allocation failure] [GC in old space requested].
   42182 ms: Mark-sweep 817.9 (1190.1) -> 793.1 (1170.1) MB, 846.9 / 0 ms [allocation failure] [GC in old space requested].
   43026 ms: Mark-sweep 793.1 (1170.1) -> 793.1 (1164.1) MB, 844.2 / 0 ms [last resort gc].
   43853 ms: Mark-sweep 793.1 (1164.1) -> 793.1 (1157.1) MB, 827.4 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x25135ccc9e59 <JS Object>
    1: fromString(aka fromString) [buffer.js:234] [pc=0x2d609cac28ab] (this=0x25135cc04189 <undefined>,string=0x107476424c11 <Very long string[169135508]>,encoding=0x25135ccd7aa9 <String[4]: utf8>)
    2: from [buffer.js:131] [pc=0x2d609ca35d16] (this=0x1900df8defa1 <JS Function Buffer (SharedFunctionInfo 0x25c6eff29c9)>,value=0x107476424c11 <Very long string[169135508]>,encodingOrOffset=0x2513...
[1]    30675 abort      npm search eslint-plugin

@svoop
Copy link

svoop commented May 18, 2016

Same here. On my Mac the npm search process eats slowly up to around 200MB memory, then quickly jumps to over 1.3GB and dies.

@othiym23
Copy link
Contributor

This is a known issue, and has to do with the underlying implementation of search in the CLI being pretty terrible for anything more than a couple thousand packages. Replacing the search code with something that queries an online endpoint is something the various engineering teams at npm would like to do, but it hasn't been addressed until now because it's never quite risen to the top of the priority list, and because it's something that to fix properly requires coördinated effort between multiple teams at npm, Inc.

The out of memory errors are at least partially addressed by #10615, which has stalled pending some work to make it testable (and getting the relevant changes into npm-registry-client). However, this just streams the results back from the registry's /-/all endpoint, and doesn't fix the issue of having to marshal a multi-hundreds-of-MB JSON object into RAM to perform a search, and so probably still won't work well for many users in environments where there isn't a whole lot of memory.

@mariusk
Copy link

mariusk commented May 24, 2016

I got it working by first running npm cache clean and then retrying npm search .... Worth a try!

@ghost
Copy link

ghost commented May 24, 2016

The 2nd try returns a result even without cleaning the cache.

@EricDunaway
Copy link

EricDunaway commented May 25, 2016

[email protected]
[email protected]

npm search datajs
npm ERR! Windows_NT 10.0.14316
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\abc\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "search" "datajs"
npm ERR! node v6.2.0
npm ERR! npm  v3.9.2

npm ERR! Cannot read property '_updated' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN Building the local index for the first time, please be patient

<--- Last few GCs --->

   31170 ms: Mark-sweep 826.6 (1193.2) -> 825.4 (1200.2) MB, 1018.1 / 0 ms (+ 205.6 ms in 659 steps since start of marking, biggest step 19.1 ms) [allocation failure] [GC in old space requested].
   32454 ms: Mark-sweep 825.4 (1200.2) -> 800.6 (1182.1) MB, 1284.7 / 0 ms [allocation failure] [GC in old space requested].
   33833 ms: Mark-sweep 800.6 (1182.1) -> 800.5 (1176.1) MB, 1378.7 / 0 ms [last resort gc].
   35145 ms: Mark-sweep 800.5 (1176.1) -> 800.5 (1170.1) MB, 1311.8 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 000002CD8BDC9E79 <JS Object>
    1: fromString(aka fromString) [buffer.js:234] [pc=0000032C9DE472AB] (this=000002CD8BD04189 <undefined>,string=00000075F5A952A1 <Very long string[170857919]>,encoding=000002CD8BDD63E1 <String[4]: utf8>)
    2: from [buffer.js:131] [pc=0000032C9DF5BEB6] (this=00000226117AE319 <JS Function Buffer (SharedFunctionInfo 0000038A510F0FE9)>,value=00000075F5A952A1 <Very long string[170857919]>,enco...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

worked on 3rd try but still errors

npm search datajs
npm ERR! Windows_NT 10.0.14316
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\abc\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "search" "datajs"
npm ERR! node v6.2.0
npm ERR! npm  v3.9.2

npm ERR! Cannot read property '_updated' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN Building the local index for the first time, please be patient
NAME                DESCRIPTION                                                  AUTHOR              DATE       VERSION
autodatajs          Auto data generation, primarily meant to be used for tests   =skubi              2016-02-28 0.0.6
datajs              Microsoft data.js for OData                                  =jaydata            2012-07-18 1.0.3
datajs_vanilla      Simple wrapper for using the vanilla datajs library in Node… =devployment        2014-04-24 0.1.0
datajson            Low-Level Data Manager in json file                          =philippeassis      2016-05-01 1.1.2
jaydata-odatajs     the Olingo OData Client for JavaScript library is a new…     =borzav =jaydata…   2016-01-08 4.0.0
metalsmith-datajson Metalsmith plugin which parses json files from a data…       =frontendstudio     2016-01-12 0.0.4
node-datajs                                                                                          2015-02-03
odatajs             the Olingo OData Client for JavaScript library is a new…     =hakandilek         2015-08-11 4.0.0
sc-query            A query module for datajs                                    =sitecore =dervalp… 2014-11-26 0.0.14
npm ERR! Windows_NT 10.0.14316
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\abc\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "search" "datajs"
npm ERR! node v6.2.0
npm ERR! npm  v3.9.2

npm ERR! Callback called more than once.
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\abc\Google Drive\Projects\a1\npm-debug.log

npm-debug.log
npm-debug.log.txt

@balboah
Copy link

balboah commented Jun 2, 2016

npm search react
npm WARN Building the local index for the first time, please be patient

<--- Last few GCs --->

   81033 ms: Mark-sweep 834.9 (1214.2) -> 834.7 (1221.2) MB, 659.3 / 0 ms (+ 115.7 ms in 786 steps since start of marking, biggest step 13.5 ms) [allocation failure] [GC in old space requested].
   81989 ms: Mark-sweep 834.7 (1221.2) -> 809.9 (1197.1) MB, 955.4 / 0 ms [allocation failure] [GC in old space requested].
   82969 ms: Mark-sweep 809.9 (1197.1) -> 809.9 (1191.1) MB, 980.1 / 0 ms [last resort gc].
   83981 ms: Mark-sweep 809.9 (1191.1) -> 809.9 (1184.1) MB, 1012.3 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x2d7a4f8c9e59 <JS Object>
    1: fromString(aka fromString) [buffer.js:234] [pc=0x17a28153dfcb] (this=0x2d7a4f804189 <undefined>,string=0xcc434d6c5f9 <Very long string[173063611]>,encoding=0x2d7a4f8d7aa9 <String[4]: utf8>)
    2: from [buffer.js:131] [pc=0x17a281955a16] (this=0xfeef0857a29 <JS Function Buffer (SharedFunctionInfo 0x38c58c6f29a9)>,value=0xcc434d6c5f9 <VeAbort trap: 6
npm --version
3.8.9

node --version
v6.2.0

sw_vers
ProductName:    Mac OS X
ProductVersion: 10.10.5
BuildVersion:   14F1808

@andreportela
Copy link

Same thing happening here

$ npm search flowchart
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/Cellar/node/6.2.0/bin/node" "/usr/local/bin/npm" "search" "flowchart"
npm ERR! node v6.2.0
npm ERR! npm  v3.9.5

npm ERR! Cannot read property '_updated' of undefined
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN Building the local index for the first time, please be patient

<--- Last few GCs --->

   89305 ms: Mark-sweep 840.8 (1212.3) -> 839.5 (1219.3) MB, 669.0 / 0 ms (+ 144.2 ms in 880 steps since start of marking, biggest step 14.2 ms) [allocation failure] [GC in old space requested].
   90396 ms: Mark-sweep 839.5 (1219.3) -> 814.6 (1200.1) MB, 1091.2 / 0 ms [allocation failure] [GC in old space requested].
   91437 ms: Mark-sweep 814.6 (1200.1) -> 814.5 (1194.1) MB, 1040.8 / 0 ms [last resort gc].
   92467 ms: Mark-sweep 814.5 (1194.1) -> 814.5 (1187.1) MB, 1030.2 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x1b8201dc9e59 <JS Object>
    1: fromString(aka fromString) [buffer.js:234] [pc=0x12eef20ca92b] (this=0x1b8201d04189 <undefined>,string=0x2d1354ecd279 <Very long string[174148194]>,encoding=0x1b8201dd7aa9 <String[4]: utf8>)
    2: from [buffer.js:131] [pc=0x12eef205add6] (this=0x91843f5b99 <JS Function Buffer (SharedFunctionInfo 0x3625945f29b1)>,value=0x2d1354ecd279 Abort trap: 6
$ node -v
v6.2.0
$ npm -v
3.9.5

npm cache clean has worked once.
After cleaning the cache I executed again npm search flowchart. It took forever building the local index

npm WARN Building the local index for the first time, please be patient
▐ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟

and then it gave me the proper output

NAME                          DESCRIPTION                                                  AUTHOR             DATE       VERSION KEYWORDS     
angularjs-flowchart           AngularJS-FlowChart ===================                      =gang.li           2016-03-31 1.0.0                
decisiontreejs                A utility module providing asynchronous control flow…        =petecleary        2013-02-26 0.1.0   javascript co
dgeni-diagrams-package        Mermaid diagrams for Dgeni documentation generator           =wingedfox         2016-02-18 0.0.3   dgeni angular
diagrams                      Generate Flowcharts, Network Sequence, Dot, and Railroad…    =francoislaberge   2016-01-03 0.6.8   flowchart seq
chart       =misaka            2016-05-12 1.1.4   flowchart flo
flowchart.js                  [![JS.ORG](https://img.shields.io/badge/js.org-flowchart-ff… =adrai             2016-05-26 1.6.3   flowchart cli
flowgraph                     interactive graph editor in the browser                      =finnpauls         2015-07-01 1.0.0   diagram flow 
flowtex                       easy flowchart latex using tikz                              =pierre-luc        2016-03-27 1.6.3   easy flowchar
flowyjs                       Create flowcharts algorithmically                            =t3pleni9          2016-03-06 1.3.0   Flowchart Alg
gitbook-plugin-flowchart      flowchart.js plugin for GitBook                              =midnightsuyama    2016-02-25 1.1.0   flowchart plu
gitbook-plugin-flowchart-full Flowchart plugin for gitbook                                 =yinyongcom666     2016-06-04 1.1.1   gitbook-plugi
gitbook-plugin-new-flowchart  flowchart.js plugin for gitbook                              =nsdont            2016-04-13 0.0.2   flowchart git
gojs                          Interactive diagrams, charts, and graphs, such as trees,…    =gojs =simonsarris 2016-05-23 1.6.9   diagram chart
jointjs                       JavaScript diagramming library                               =chill1…           2016-05-31 0.9.9   diagram flowc
jquery.flowchart              JQuery UI plugin that allows you to draw a flow chart.       =sdrdis            2016-05-14 1.1.0   flowchart flo
mermaid                       Markdownish syntax for generating flowcharts, sequence…      =knsv              2016-05-29 6.0.0   diagram markd
pcnchart                      Create an SVG string to display Process Chain Network data   =tgroshon          2014-12-04 0.10.1  pcn svg flowc
react-flowchart               An interactive flowchart using React                         =wunderlink        2015-08-18 1.3.5                
react-mermaid                 A react component to display mermaid diagrams and…           =jasonbellamy      2015-08-28 0.1.3   react react-c

The thing is: I've to clean the cache every time I want to perform a search, it takes forever and it crashes randomly.

My machine is a macbook air with 8GB RAM, Core i7, SSD and OS X El Capitan. It's not that bad at all.

@antjkennedy
Copy link

@andreportela the best bet for the time being is to create an alias for npm allocating enough memory for the search.

node --max-old-space-size=4000 /usr/local/bin/npm search angular

Running the above search complete, but uses 2.2GB of memory 😐

screen shot 2016-06-08 at 11 10 46

@andreportela
Copy link

@antjkennedy thanks!

  • It took forever building the cache;
  • It threw some errors
    • Cannot read property '_updated' of undefined;
    • Callback called more than once.
  • But returned what I asked:
$ node --max-old-space-size=4000 /usr/local/bin/npm search flowchart
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/Cellar/node/6.2.0/bin/node" "/usr/local/bin/npm" "search" "flowchart"
npm ERR! node v6.2.0
npm ERR! npm  v3.9.5

npm ERR! Cannot read property '_updated' of undefined
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN Building the local index for the first time, please be patient
NAME                          DESCRIPTION                                                  AUTHOR             DATE      
angularjs-flowchart           AngularJS-FlowChart ===================                      =gang.li           2016-03-31
decisiontreejs                A utility module providing asynchronous control flow…        =petecleary        2013-02-26
dgeni-diagrams-package        Mermaid diagrams for Dgeni documentation generator           =wingedfox         2016-02-18
diagrams                      Generate Flowcharts, Network Sequence, Dot, and Railroad…    =francoislaberge   2016-01-03
flowchart                     a quick utility for walking through a flowchart              =pmcelhaney        2015-04-17
flowchart-render              the render part for http://elemefe.github.io/flowchart       =misaka            2016-05-12
flowchart.js                  [![JS.ORG](https://img.shields.io/badge/js.org-flowchart-ff… =adrai             2016-05-26
flowgraph                     interactive graph editor in the browser                      =finnpauls         2015-07-01
flowtex                       easy flowchart latex using tikz                              =pierre-luc        2016-03-27
flowyjs                       Create flowcharts algorithmically                            =t3pleni9          2016-03-06
gitbook-plugin-flowchart      flowchart.js plugin for GitBook                              =midnightsuyama    2016-02-25
gitbook-plugin-flowchart-full Flowchart plugin for gitbook                                 =yinyongcom666     2016-06-04
gitbook-plugin-new-flowchart  flowchart.js plugin for gitbook                              =nsdont            2016-04-13
gojs                          Interactive diagrams, charts, and graphs, such as trees,…    =gojs =simonsarris 2016-05-23
jointjs                       JavaScript diagramming library                               =chill1…           2016-05-31
jquery.flowchart              JQuery UI plugin that allows you to draw a flow chart.       =sdrdis            2016-05-14
mermaid                       Markdownish syntax for generating flowcharts, sequence…      =knsv              2016-05-29
pcnchart                      Create an SVG string to display Process Chain Network data   =tgroshon          2014-12-04
react-flowchart               An interactive flowchart using React                         =wunderlink        2015-08-18
react-mermaid                 A react component to display mermaid diagrams and…           =jasonbellamy      2015-08-28
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/Cellar/node/6.2.0/bin/node" "/usr/local/bin/npm" "search" "flowchart"
npm ERR! node v6.2.0
npm ERR! npm  v3.9.5

npm ERR! Callback called more than once.
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/myuser/myproject/npm-debug.log

Subsequent calls using same command worked well :)

I'm just wondering the size of the cache it built and where can I find this cache?

@neoswf
Copy link

neoswf commented Jun 16, 2016

@andreportela - run npm cache clean. It will do the trick regarding the cache only. Regarding the memory dump - no idea.....

@othiym23
Copy link
Contributor

othiym23 commented Jun 28, 2016

As the registry continues to grow beyond 300,000 packages, this problem (which is really more a design flaw than a bug) is only going to grow more severe. The CLI team may land a variant of #10615 if we can figure out how to make it work with Node 6, or we may just (temporarily) remove CLI search altogether. Until the team has the time to address this more comprehensively, my recommendation is to use web search, either via https://www.npm.com or via one of the many alternatives, such as https://npms.io or http://node-modules.com.

@ralphtheninja
Copy link

It seems it has to be http://node-modules.com and not https. Also check out the cli tool for node-modules.com https://github.com/mafintosh/node-modules-cli

A search for flowchart (as done above) would look like:

node-modules-cli

@alextes
Copy link

alextes commented Oct 5, 2016

'opened this issue on May 8' makes me want to apply for a job at npm :3 . Good luck with all the work npm team! You can do it!

@monolithed
Copy link

The same problem:

22:16:10 <--- Last few GCs --->
22:16:10 
22:16:10  8769916 ms: Mark-sweep 1375.7 (1434.2) -> 1372.9 (1431.4) MB, 172.6 / 0 ms [allocation failure] [GC in old space requested].
22:16:10  8770099 ms: Mark-sweep 1372.9 (1431.4) -> 1372.9 (1431.4) MB, 182.9 / 0 ms [allocation failure] [GC in old space requested].
22:16:10  8770275 ms: Mark-sweep 1372.9 (1431.4) -> 1372.8 (1431.4) MB, 176.3 / 0 ms [last resort gc].
22:16:10  8770459 ms: Mark-sweep 1372.8 (1431.4) -> 1372.8 (1431.4) MB, 184.3 / 0 ms [last resort gc].
22:16:10 
22:16:10 
22:16:10 <--- JS stacktrace --->
22:16:10 
22:16:10 ==== JS stack trace =========================================
22:16:10 
22:16:10 Security context: 0x3dd9136c9e31 <JS Object>
22:16:10     1: indexOf [native string.js:~66] [pc=0x8c281d1672a] (this=0x1986f3f15699 <Very long string[3046389]>,y=0xcda6f94a1 <String[1]\: \n>,z=0)
22:16:10     2: onread [internal/child_process.js:~426] [pc=0x8c281bcbd40] (this=0x3b10e74f271 <a Pipe with map 0x6f461ced6d1>,nread=65536,pool=0x1986f3f15629 <an Uint8Array with map 0x6f461cf83b9>,recvHandle=0x3dd913604189 <undefined>)
22:16:10 
22:16:10 ==== Details =============...
22:16:10 
22:16:10 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
22:16:10  1: node::Abort() [grunt]
22:16:10  2: 0xfbdfac [grunt]
22:16:10  3: v8::Utils::ReportApiFailure(char const*, char const*) [grunt]
22:16:10  4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [grunt]
22:16:10  5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [grunt]
22:16:10  6: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [grunt]
22:16:10  7: v8::internal::StringMatch(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, int) [grunt]
22:16:10  8: v8::internal::Runtime_StringIndexOf(int, v8::internal::Object**, v8::internal::Isolate*) [grunt]
22:16:10  9: 0x8c28150961b
22:16:11 Aborted (core dumped)
22:16:11 
22:16:11 npm ERR! Linux 4.2.0-38-generic

@ypetya
Copy link

ypetya commented Oct 6, 2016

changed my npm wrapper as the following

npm gist

export NODE_MEMORY=8000
npm search angular

@kenany kenany mentioned this issue Oct 12, 2016
1 task
@voppe
Copy link

voppe commented Oct 17, 2016

Had the same problem on Windows, but I found a temporary workaround based on @ypetya's solution.

Open C:\Program Files\nodejs\npm.cmd in any editor and replace its content with this gist

Then open a terminal and

set NODE_MEMORY=8000
npm search angular

@buehler
Copy link

buehler commented Oct 20, 2016

Hey guys. Could you please tell me (us?) in which version this - like veeeeery - annoying bug will be fixed? To be honest, it's one of the biggest usecases to search for packages.

I'm sorry, but I'm frustrated by this issue for the 99th time :-(

@alextes
Copy link

alextes commented Oct 20, 2016

Look at #13746 @buehler. As zkat already mentioned on Aug 24th in this thread 😉. Until then npms.io is a very fit alternative in my experience.

@buehler
Copy link

buehler commented Oct 20, 2016

@alextes Well it is merged 😉
But thanks for the npms.io alternative! Made my day!

@zkat
Copy link
Contributor

zkat commented Oct 20, 2016

npm@4 is being released today. That'll include the patch.

@alextes
Copy link

alextes commented Oct 20, 2016

You're welcome @buehler ^^
Today?! Much excite @zkat!! Congratulate an npm member for me!

@zkat zkat closed this as completed in 2b8057b Oct 21, 2016
@ghost
Copy link

ghost commented Oct 21, 2016

It just took us seven months to build a slow search feature which gladly crashes only at the end of the search procedure.

@ghost ghost mentioned this issue Oct 21, 2016
13 tasks
@almosnow
Copy link

almosnow commented Oct 21, 2016

(More like 6 years)

[sexist commentary moderated]

Yeah my comment was actually against sexism ... but one can never please you guys.

@felipead
Copy link

Same here.

$ npm cache clean
$ npm search speed-test
npm WARN Building the local index for the first time, please be patient
⸨░░░░░░░░░░░░░░░░░░⸩ ⠼ : WARN Building the local index for the first time, please be patient
<--- Last few GCs --->

[1595:0x102801600]   123597 ms: Mark-sweep 1037.1 (1350.9) -> 1031.3 (1346.0) MB, 1200.5 / 0.0 ms  allocation failure GC in old space requested
[1595:0x102801600]   124912 ms: Mark-sweep 1031.3 (1346.0) -> 1031.2 (1308.0) MB, 1314.4 / 0.0 ms  last resort gc 
[1595:0x102801600]   126203 ms: Mark-sweep 1031.2 (1308.0) -> 1031.1 (1301.0) MB, 1291.4 / 0.0 ms  last resort gc 


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3c1a544c0d11 <JS Object>
    1: fromString(aka fromString) [buffer.js:217] [pc=0x95fef9c126e](this=0x3c1a54404311 <undefined>,string=0x2ff29950c589 <Very long string[215963457]>,encoding=0x3c1a544c9921 <String[4]: utf8>)
    2: from [buffer.js:114] [pc=0x95fef9c0eb0](this=0x7505f9a9969 <JS Function Buffer (SharedFunctionInfo 0x3c1a544e2e39)>,value=0x2ff29950c589 <Very long string[215963457]>,encodingOrOffset=0x3c1a544c...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/usr/local/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [/usr/local/bin/node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
 5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
 6: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/usr/local/bin/node]
 7: v8::String::WriteUtf8(char*, int, int*, int) const [/usr/local/bin/node]
 8: node::StringBytes::Write(v8::Isolate*, char*, unsigned long, v8::Local<v8::Value>, node::encoding, int*) [/usr/local/bin/node]
 9: node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) [/usr/local/bin/node]
10: node::Buffer::CreateFromString(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
11: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/bin/node]
12: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
13: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
14: 0x95fef4063a7
15: 0x95fef9c126e
16: 0x95fef9c0eb0
17: 0x95fef407e55
Abort trap: 6

npm version: 3.10.9
node version: v7.1.0

Installed on macOS 10.12.1 using homebrew.

@kenany
Copy link
Contributor

kenany commented Nov 13, 2016

@felipead As mentioned above, this was fixed in [email protected].

@felipead
Copy link

felipead commented Nov 13, 2016

Thanks! Will try to install this version then.

@grantgeorge
Copy link

upgrade to npm@4 as @zkat mentioned and you're solid!

npm install npm@latest -g

@doomsbuster
Copy link

The issue is fixed with npm@4. Thanks a lot for the hard work. I also liked the small little smiley on the CLI while its searching. Good job.

@Zorgatone
Copy link

✘ tommaso@TR  ~  npm --version
3.10.10
 tommaso@TR  ~  sudo npm install --global npm
Password:
/Users/tommaso/.npm-global/bin/npm -> /Users/tommaso/.npm-global/lib/node_modules/npm/bin/npm-cli.js
/Users/tommaso/.npm-global/lib
└── [email protected]

 tommaso@TR  ~  npm --version
3.10.10
 tommaso@TR  ~  npm search pikaday
npm WARN Building the local index for the first time, please be patient
⸨░░░░░░░░░░░░░░░░░░⸩ ⠦ : WARN Building the local index for the first time, plea
<--- Last few GCs --->

[1922:0x102801600]    41032 ms: Mark-sweep 1079.0 (1431.0) -> 1077.9 (1433.0) MB, 993.7 / 0.0 ms  allocation failure GC in old space requested
[1922:0x102801600]    42024 ms: Mark-sweep 1077.9 (1433.0) -> 1077.9 (1395.0) MB, 992.4 / 0.0 ms  last resort gc
[1922:0x102801600]    43003 ms: Mark-sweep 1077.9 (1395.0) -> 1077.7 (1388.0) MB, 978.9 / 0.0 ms  last resort gc


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x2d37e86c0d39 <JS Object>
    1: fromString(aka fromString) [buffer.js:207] [pc=0x4d00f9ccb6e](this=0x2d37e8604311 <undefined>,string=0x489edc0c331 <Very long string[226750292]>,encoding=0x2d37e86c9949 <String[4]: utf8>)
    2: from [buffer.js:104] [pc=0x4d00f9638b0](this=0x2d17f0aabfd1 <JS Function Buffer (SharedFunctionInfo 0x2d37e86e2d91)>,value=0x489edc0c331 <Very long string[226750292]>,encodingOrOffset=0x2d37e86c9...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/usr/local/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
 4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
 5: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/usr/local/bin/node]
 6: v8::String::WriteUtf8(char*, int, int*, int) const [/usr/local/bin/node]
 7: node::StringBytes::Write(v8::Isolate*, char*, unsigned long, v8::Local<v8::Value>, node::encoding, int*) [/usr/local/bin/node]
 8: node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) [/usr/local/bin/node]
 9: node::Buffer::CreateFromString(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
10: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/bin/node]
11: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
12: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
13: 0x4d00f4063a7
14: 0x4d00f9ccb6e
15: 0x4d00f9638b0
16: 0x4d00f407e55
[1]    1922 abort      npm search pikaday

@Zorgatone
Copy link

 ✘ tommaso@TR  ~  npm search npm
npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "search" "npm"
npm ERR! node v7.3.0
npm ERR! npm  v3.10.10

npm ERR! Cannot read property '_updated' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN Building the local index for the first time, please be patient

@varjmes
Copy link

varjmes commented Jan 9, 2017

Please update to the latest version of npm, where search is now fixed.

npm install -g npm@latest

@ddmee
Copy link

ddmee commented Jan 26, 2017

@Charlotteis thanks for that. That's the fix I needed.

When I downloaded the latest stable release of Node, the NPM version that comes bundled caused the JavaScript heap issue everyone in this thread is complaining about. This happened on two different Windows 10 machines.

After updating NPM as advised by @Charlotteis - the issue is fixed.

But why is a broken NPM being distributed within the main stable download of Node (v6.9.4 lts)? This seems a bit stupid.

@zkat
Copy link
Contributor

zkat commented Jan 26, 2017

@ddmee npm@4 is being brought into node@6. It's just not that simple because this was a (necessarily) breaking npm change and node LTS policy is to not take major dependency bumps like that, so there needed to be some discussion. "Don't ship broken things" definitely prioritizes things that affect the core functionality for npm: installation. Secondary things like CLI search are understandably lower priority if it involves breaking changes.

@zkat
Copy link
Contributor

zkat commented Jan 26, 2017

Since we keep getting questions about this long after the fixed version has been released, I'm going to lock this issue with the following message for those who haven't read the thread:

If you experience this issue with npm search, upgrade to at least npm@4 by doing npm install -g npm@latest. This issue has been resolved already. Please don't create further issues if you have a sub-npm@4 version.

@npm npm locked and limited conversation to collaborators Jan 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests