ember-native-class-codemod icon indicating copy to clipboard operation
ember-native-class-codemod copied to clipboard

Evaluation failed: TypeError: Cannot read property 'entries'

Open mcfiredrill opened this issue 6 years ago • 6 comments

I'm trying to run this on my app on OSX. I'm not really sure if chromium is actually running correctly.

☯tony@okirakugokiraku☯ ~/src/datafruits(master)$ npx ember-native-class-codemod http://localhost:4200/ app/**/*
.js                                                                                                            
Downloading Chromium r686378 - 110.2 Mb [====================] 100% 0.0s                                       
(node:10974) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property 'entri
es' of undefined                                                                                               
    at __puppeteer_evaluation_script__:7:48                                                                    
    at ExecutionContext._evaluateInternal (/Users/tony/.npm/_npx/10974/lib/node_modules/ember-native-class-code
mod/node_modules/puppeteer/lib/ExecutionContext.js:122:13)                                                     
    at process._tickCallback (internal/process/next_tick.js:68:7)                                              
  -- ASYNC --                                                                                                  
    at ExecutionContext.<anonymous> (/Users/tony/.npm/_npx/10974/lib/node_modules/ember-native-class-codemod/no
de_modules/puppeteer/lib/helper.js:111:15)                                                                     
    at DOMWorld.evaluate (/Users/tony/.npm/_npx/10974/lib/node_modules/ember-native-class-codemod/node_modules/
puppeteer/lib/DOMWorld.js:112:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  -- ASYNC --

mcfiredrill avatar Nov 11 '19 10:11 mcfiredrill

It looks like the page is not loading Ember. We've had this happen with for instance applications that redirect to a non-Ember sign-in page when they attempt to run the codemod, as the Puppeteer instance of Chromium does not have any cookies or session data shared with standard Chrome. It can also happen if the app is not running.

Our recommendation is typically to pass a URL to the tests page for the app, cause that will usually not redirect or require any kind of auth or anything. Can you give that a shot?

pzuraq avatar Nov 11 '19 17:11 pzuraq

Thank you! I don't have a sign-in page, but there may be something else causing a problem. I tried using the test server's page instead and that seems to have worked.

☯tony@okirakugokiraku☯ ~/src/datafruits(master *)$ npx ember-native-class-codemod http://localhost:7357/502125111151582/tests/index.html app/**/*.js

I got many errors related to libraries/addons, although the codemod appears to have been run successfully anyway!

error evaluating `ember-local-storage/test-support/reset-storage`: Could not find module `ember-local-storage/helpers/sto
rage` imported from `ember-local-storage/test-support/reset-storage`                                                     
error evaluating `datafruits13/adapters/application`: Could not find module `active-model-adapter` imported from `datafru
its13/adapters/application`                                                                                              
error evaluating `datafruits13/adapters/dj`: Cannot read property 'exports' of undefined                                 
error evaluating `datafruits13/adapters/host-application`: Cannot read property 'exports' of undefined                   
error evaluating `datafruits13/adapters/label`: Cannot read property 'exports' of undefined                              
error evaluating `datafruits13/adapters/podcast`: Cannot read property 'exports' of undefined                            
error evaluating `datafruits13/adapters/scheduled-show`: Cannot read property 'exports' of undefined                     
error evaluating `datafruits13/components/as-calendar`: Could not find module `ember-calendar/components/as-calendar` imp
orted from `datafruits13/components/as-calendar`                                                                         
error evaluating `datafruits13/components/as-calendar/header`: Could not find module `ember-calendar/components/as-calend
ar/header` imported from `datafruits13/components/as-calendar/header`                                                    
error evaluating `datafruits13/components/as-calendar/occurrence`: Could not find module `ember-calendar/components/as-ca
lendar/occurrence` imported from `datafruits13/components/as-calendar/occurrence`                                        
error evaluating `datafruits13/components/as-calendar/timetable`: Could not find module `ember-calendar/components/as-cal
endar/timetable` imported from `datafruits13/components/as-calendar/timetable`                                           
error evaluating `datafruits13/components/as-calendar/timetable/content`: Could not find module `ember-calendar/component
s/as-calendar/timetable/content` imported from `datafruits13/components/as-calendar/timetable/content`                   
error evaluating `datafruits13/components/as-calendar/timetable/occurrence`: Could not find module `ember-calendar/compon
ents/as-calendar/timetable/occurrence` imported from `datafruits13/components/as-calendar/timetable/occurrence`          
error evaluating `datafruits13/components/assert-must-preload`: Could not find module `ember-data-storefront/components/a
ssert-must-preload/component` imported from `datafruits13/components/assert-must-preload`                                
error evaluating `datafruits13/components/basic-dropdown`: Could not find module `ember-basic-dropdown/components/basic-d
ropdown` imported from `datafruits13/components/basic-dropdown`                                                          
error evaluating `datafruits13/components/basic-dropdown/content-element`: Could not find module `ember-basic-dropdown/co........

mcfiredrill avatar Nov 12 '19 07:11 mcfiredrill

I'm also getting this error, and we also do not not redirect to a non-ember sign in page.

I also tried the test page, but that failed w/ the same error:

npx ember-native-class-codemod https://localhost:4201/1023991841793938/tests/index.html app/**/*.js
(node:15890) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property 'entries' of undefined
    at __puppeteer_evaluation_script__:7:48
    at ExecutionContext._evaluateInternal (/Users/tom6947/.nvm/versions/node/v10.16.1/lib/node_modules/ember-native-class-codemod/node_modules/puppeteer/lib/ExecutionContext.js:122:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Do the pupeteer scripts by chance try to call window.require, b/c we use an addon that has to rename that global b/c Ember does not expose the loader's no-conflict mode.

tomwayson avatar Apr 21 '20 22:04 tomwayson

Yep, it looks like this line is the culprit:

https://github.com/ember-codemods/ember-codemods-telemetry-helpers/blob/574248cae753f880885155e94ad5b206c9f59a68/lib/gather/gather-telemetry.js#L36

tomwayson avatar Apr 22 '20 13:04 tomwayson

I'm able to get passed the above error by modifying that line and this one locally in my node_modules folder.

Like @mcfiredrill I see many errors in the terminal output, but ultimately it finishes with

Results: 
0 errors
105 unmodified
0 skipped
162 ok
Time elapsed: 9.308seconds 

tomwayson avatar Apr 22 '20 23:04 tomwayson

The only thing that resolved this issue and #314 for me is using the fork from MichalBryxi from the comment above:

npx git+https://github.com/MichalBryxi/ember-native-class-codemod.git#bump-ember-codemods-telemetry-helpers http://localhost:4200/ app/routes/application.js

pointing to the tests did unfortunately not help in any way.

st-h avatar Jul 30 '20 14:07 st-h